+ int_fc = bt2.IntegerFieldClass(32)
+ str_fc = bt2.StringFieldClass()
+ struct_fc = bt2.StructureFieldClass()
+ struct_fc.append_field(field_class=int_fc, name='an_int')
+ struct_fc.append_field(field_class=str_fc, name='a_string')
+ struct_fc.append_field(field_class=int_fc, name='another_int')
+
+ struct = struct_fc()
+ struct.value = values
+ self.assertTrue(struct.is_set)
+ struct.reset()
+ self.assertEqual(struct_fc(), struct)
+
+ def test_str_op(self):
+ expected_string_found = False
+ s = str(self._def)
+ # Establish all permutations of the three expected matches since
+ # the order in which mappings are enumerated is not explicitly part of
+ # the API.
+ for p in itertools.permutations([(k, v) for k, v in self._def.items()]):
+ items = ['{}: {}'.format(repr(k), repr(v)) for k, v in p]
+ candidate = '{{{}}}'.format(', '.join(items))
+ if candidate == s:
+ expected_string_found = True
+ break
+
+ self.assertTrue(expected_string_found)
+
+ def test_str_op_unset(self):
+ self.assertEqual(str(self._fc()), 'Unset')