8 def _test_copy(self
, cpy
):
9 self
.assertIsNot(cpy
, self
._fc
)
10 self
.assertNotEqual(cpy
.addr
, self
._fc
.addr
)
11 self
.assertEqual(cpy
, self
._fc
)
14 cpy
= copy
.copy(self
._fc
)
17 def test_deepcopy(self
):
18 cpy
= copy
.deepcopy(self
._fc
)
22 class _TestAlignmentProp
:
23 def test_assign_alignment(self
):
24 self
._fc
.alignment
= 32
25 self
.assertEqual(self
._fc
.alignment
, 32)
27 def test_assign_invalid_alignment(self
):
28 with self
.assertRaises(ValueError):
29 self
._fc
.alignment
= 23
32 class _TestByteOrderProp
:
33 def test_assign_byte_order(self
):
34 self
._fc
.byte_order
= bt2
.ByteOrder
.LITTLE_ENDIAN
35 self
.assertEqual(self
._fc
.byte_order
, bt2
.ByteOrder
.LITTLE_ENDIAN
)
37 def test_assign_invalid_byte_order(self
):
38 with self
.assertRaises(TypeError):
39 self
._fc
.byte_order
= 'hey'
43 def test_eq_invalid(self
):
44 self
.assertFalse(self
._fc
== 23)
47 class _TestIntegerFieldClassProps
:
48 def test_size_prop(self
):
49 self
.assertEqual(self
._fc
.size
, 35)
51 def test_assign_signed(self
):
52 self
._fc
.is_signed
= True
53 self
.assertTrue(self
._fc
.is_signed
)
55 def test_assign_invalid_signed(self
):
56 with self
.assertRaises(TypeError):
57 self
._fc
.is_signed
= 23
59 def test_assign_base(self
):
60 self
._fc
.base
= bt2
.Base
.HEXADECIMAL
61 self
.assertEqual(self
._fc
.base
, bt2
.Base
.HEXADECIMAL
)
63 def test_assign_invalid_base(self
):
64 with self
.assertRaises(TypeError):
67 def test_assign_encoding(self
):
68 self
._fc
.encoding
= bt2
.Encoding
.UTF8
69 self
.assertEqual(self
._fc
.encoding
, bt2
.Encoding
.UTF8
)
71 def test_assign_invalid_encoding(self
):
72 with self
.assertRaises(TypeError):
73 self
._fc
.encoding
= 'hey'
75 def test_assign_mapped_clock_class(self
):
76 cc
= bt2
.ClockClass('name', 1000)
77 self
._fc
.mapped_clock_class
= cc
78 self
.assertEqual(self
._fc
.mapped_clock_class
, cc
)
80 def test_assign_invalid_mapped_clock_class(self
):
81 with self
.assertRaises(TypeError):
82 self
._fc
.mapped_clock_class
= object()
85 @unittest.skip("this is broken")
86 class IntegerFieldClassTestCase(_TestIntegerFieldClassProps
, _TestCopySimple
,
87 _TestAlignmentProp
, _TestByteOrderProp
,
88 _TestInvalidEq
, unittest
.TestCase
):
90 self
._fc
= bt2
.IntegerFieldClass(35)
95 def test_create_default(self
):
96 self
.assertEqual(self
._fc
.size
, 35)
97 self
.assertIsNone(self
._fc
.mapped_clock_class
)
99 def test_create_invalid_size(self
):
100 with self
.assertRaises(TypeError):
101 fc
= bt2
.IntegerFieldClass('yes')
103 def test_create_neg_size(self
):
104 with self
.assertRaises(ValueError):
105 fc
= bt2
.IntegerFieldClass(-2)
107 def test_create_neg_zero(self
):
108 with self
.assertRaises(ValueError):
109 fc
= bt2
.IntegerFieldClass(0)
111 def test_create_full(self
):
112 cc
= bt2
.ClockClass('name', 1000)
113 fc
= bt2
.IntegerFieldClass(24, alignment
=16,
114 byte_order
=bt2
.ByteOrder
.BIG_ENDIAN
,
115 is_signed
=True, base
=bt2
.Base
.OCTAL
,
116 encoding
=bt2
.Encoding
.NONE
,
117 mapped_clock_class
=cc
)
118 self
.assertEqual(fc
.size
, 24)
119 self
.assertEqual(fc
.alignment
, 16)
120 self
.assertEqual(fc
.byte_order
, bt2
.ByteOrder
.BIG_ENDIAN
)
121 self
.assertTrue(fc
.is_signed
)
122 self
.assertEqual(fc
.base
, bt2
.Base
.OCTAL
)
123 self
.assertEqual(fc
.encoding
, bt2
.Encoding
.NONE
)
124 self
.assertEqual(fc
.mapped_clock_class
, cc
)
126 def test_create_field(self
):
128 self
.assertIsInstance(field
, bt2
.field
._IntegerField
)
130 def test_create_field_init(self
):
132 self
.assertEqual(field
, 23)
135 @unittest.skip("this is broken")
136 class FloatingPointNumberFieldClassTestCase(_TestCopySimple
, _TestAlignmentProp
,
137 _TestByteOrderProp
, _TestInvalidEq
,
140 self
._fc
= bt2
.FloatingPointNumberFieldClass()
145 def test_create_default(self
):
148 def test_create_full(self
):
149 fc
= bt2
.FloatingPointNumberFieldClass(alignment
=16,
150 byte_order
=bt2
.ByteOrder
.BIG_ENDIAN
,
153 self
.assertEqual(fc
.alignment
, 16)
154 self
.assertEqual(fc
.byte_order
, bt2
.ByteOrder
.BIG_ENDIAN
)
155 self
.assertEqual(fc
.exponent_size
, 11)
156 self
.assertEqual(fc
.mantissa_size
, 53)
158 def test_assign_exponent_size(self
):
159 self
._fc
.exponent_size
= 8
160 self
.assertEqual(self
._fc
.exponent_size
, 8)
162 def test_assign_invalid_exponent_size(self
):
163 with self
.assertRaises(TypeError):
164 self
._fc
.exponent_size
= 'yes'
166 def test_assign_mantissa_size(self
):
167 self
._fc
.mantissa_size
= 24
168 self
.assertEqual(self
._fc
.mantissa_size
, 24)
170 def test_assign_invalid_mantissa_size(self
):
171 with self
.assertRaises(TypeError):
172 self
._fc
.mantissa_size
= 'no'
174 def test_create_field(self
):
176 self
.assertIsInstance(field
, bt2
.field
._FloatingPointNumberField
)
178 def test_create_field_init(self
):
179 field
= self
._fc
(17.5)
180 self
.assertEqual(field
, 17.5)
183 @unittest.skip("this is broken")
184 class EnumerationFieldClassTestCase(_TestIntegerFieldClassProps
, _TestInvalidEq
,
185 _TestCopySimple
, _TestAlignmentProp
,
186 _TestByteOrderProp
, unittest
.TestCase
):
188 self
._fc
= bt2
.EnumerationFieldClass(size
=35)
193 def test_create_from_int_fc(self
):
194 int_fc
= bt2
.IntegerFieldClass(23)
195 self
._fc
= bt2
.EnumerationFieldClass(int_fc
)
197 def test_create_from_invalid_type(self
):
198 with self
.assertRaises(TypeError):
199 self
._fc
= bt2
.EnumerationFieldClass('coucou')
201 def test_create_from_invalid_fc(self
):
202 with self
.assertRaises(TypeError):
203 fc
= bt2
.FloatingPointNumberFieldClass()
204 self
._fc
= bt2
.EnumerationFieldClass(fc
)
206 def test_create_full(self
):
207 fc
= bt2
.EnumerationFieldClass(size
=24, alignment
=16,
208 byte_order
=bt2
.ByteOrder
.BIG_ENDIAN
,
209 is_signed
=True, base
=bt2
.Base
.OCTAL
,
210 encoding
=bt2
.Encoding
.NONE
,
211 mapped_clock_class
=None)
212 self
.assertEqual(fc
.size
, 24)
213 self
.assertEqual(fc
.alignment
, 16)
214 self
.assertEqual(fc
.byte_order
, bt2
.ByteOrder
.BIG_ENDIAN
)
215 self
.assertTrue(fc
.is_signed
)
216 self
.assertEqual(fc
.base
, bt2
.Base
.OCTAL
)
217 self
.assertEqual(fc
.encoding
, bt2
.Encoding
.NONE
)
218 #self.assertIsNone(fc.mapped_clock_class)
220 def test_integer_field_class_prop(self
):
221 int_fc
= bt2
.IntegerFieldClass(23)
222 enum_fc
= bt2
.EnumerationFieldClass(int_fc
)
223 self
.assertEqual(enum_fc
.integer_field_class
.addr
, int_fc
.addr
)
225 def test_add_mapping_simple(self
):
226 self
._fc
.add_mapping('hello', 24)
227 mapping
= self
._fc
[0]
228 self
.assertEqual(mapping
.name
, 'hello')
229 self
.assertEqual(mapping
.lower
, 24)
230 self
.assertEqual(mapping
.upper
, 24)
232 def test_add_mapping_simple_kwargs(self
):
233 self
._fc
.add_mapping(name
='hello', lower
=17, upper
=23)
234 mapping
= self
._fc
[0]
235 self
.assertEqual(mapping
.name
, 'hello')
236 self
.assertEqual(mapping
.lower
, 17)
237 self
.assertEqual(mapping
.upper
, 23)
239 def test_add_mapping_range(self
):
240 self
._fc
.add_mapping('hello', 21, 199)
241 mapping
= self
._fc
[0]
242 self
.assertEqual(mapping
.name
, 'hello')
243 self
.assertEqual(mapping
.lower
, 21)
244 self
.assertEqual(mapping
.upper
, 199)
246 def test_add_mapping_invalid_name(self
):
247 with self
.assertRaises(TypeError):
248 self
._fc
.add_mapping(17, 21, 199)
250 def test_add_mapping_invalid_signedness_lower(self
):
251 with self
.assertRaises(ValueError):
252 self
._fc
.add_mapping('hello', -21, 199)
254 def test_add_mapping_invalid_signedness_upper(self
):
255 with self
.assertRaises(ValueError):
256 self
._fc
.add_mapping('hello', 21, -199)
258 def test_add_mapping_simple_signed(self
):
259 self
._fc
.is_signed
= True
260 self
._fc
.add_mapping('hello', -24)
261 mapping
= self
._fc
[0]
262 self
.assertEqual(mapping
.name
, 'hello')
263 self
.assertEqual(mapping
.lower
, -24)
264 self
.assertEqual(mapping
.upper
, -24)
266 def test_add_mapping_range_signed(self
):
267 self
._fc
.is_signed
= True
268 self
._fc
.add_mapping('hello', -21, 199)
269 mapping
= self
._fc
[0]
270 self
.assertEqual(mapping
.name
, 'hello')
271 self
.assertEqual(mapping
.lower
, -21)
272 self
.assertEqual(mapping
.upper
, 199)
275 enum_fc
= bt2
.EnumerationFieldClass(size
=16)
276 enum_fc
.add_mapping('c', 4, 5)
277 enum_fc
.add_mapping('d', 6, 18)
278 enum_fc
.add_mapping('e', 20, 27)
279 self
._fc
.add_mapping('a', 0, 2)
280 self
._fc
.add_mapping('b', 3)
282 self
.assertEqual(self
._fc
[0].name
, 'a')
283 self
.assertEqual(self
._fc
[0].lower
, 0)
284 self
.assertEqual(self
._fc
[0].upper
, 2)
285 self
.assertEqual(self
._fc
[1].name
, 'b')
286 self
.assertEqual(self
._fc
[1].lower
, 3)
287 self
.assertEqual(self
._fc
[1].upper
, 3)
288 self
.assertEqual(self
._fc
[2].name
, 'c')
289 self
.assertEqual(self
._fc
[2].lower
, 4)
290 self
.assertEqual(self
._fc
[2].upper
, 5)
291 self
.assertEqual(self
._fc
[3].name
, 'd')
292 self
.assertEqual(self
._fc
[3].lower
, 6)
293 self
.assertEqual(self
._fc
[3].upper
, 18)
294 self
.assertEqual(self
._fc
[4].name
, 'e')
295 self
.assertEqual(self
._fc
[4].lower
, 20)
296 self
.assertEqual(self
._fc
[4].upper
, 27)
298 def test_bool_op(self
):
299 self
.assertFalse(self
._fc
)
300 self
._fc
.add_mapping('a', 0)
301 self
.assertTrue(self
._fc
)
304 self
._fc
.add_mapping('a', 0)
305 self
._fc
.add_mapping('b', 1)
306 self
._fc
.add_mapping('c', 2)
307 self
.assertEqual(len(self
._fc
), 3)
309 def test_getitem(self
):
310 self
._fc
.add_mapping('a', 0)
311 self
._fc
.add_mapping('b', 1, 3)
312 self
._fc
.add_mapping('c', 5)
313 mapping
= self
._fc
[1]
314 self
.assertEqual(mapping
.name
, 'b')
315 self
.assertEqual(mapping
.lower
, 1)
316 self
.assertEqual(mapping
.upper
, 3)
326 for mapping
in mappings
:
327 self
._fc
.add_mapping(*mapping
)
329 for fc_mapping
, mapping
in zip(self
._fc
, mappings
):
330 self
.assertEqual(fc_mapping
.name
, mapping
[0])
331 self
.assertEqual(fc_mapping
.lower
, mapping
[1])
332 self
.assertEqual(fc_mapping
.upper
, mapping
[2])
334 def test_mapping_eq(self
):
335 enum1
= bt2
.EnumerationFieldClass(size
=32)
336 enum2
= bt2
.EnumerationFieldClass(size
=16)
337 enum1
.add_mapping('b', 1, 3)
338 enum2
.add_mapping('b', 1, 3)
339 self
.assertEqual(enum1
[0], enum2
[0])
341 def test_mapping_eq_invalid(self
):
342 enum1
= bt2
.EnumerationFieldClass(size
=32)
343 enum1
.add_mapping('b', 1, 3)
344 self
.assertNotEqual(enum1
[0], 23)
346 def _test_find_by_name(self
, fc
):
347 fc
.add_mapping('a', 0)
348 fc
.add_mapping('b', 1, 3)
349 fc
.add_mapping('a', 5)
350 fc
.add_mapping('a', 17, 144)
351 fc
.add_mapping('C', 5)
352 mapping_iter
= fc
.mappings_by_name('a')
353 mappings
= list(mapping_iter
)
359 for mapping
in mappings
:
361 self
.assertEqual(mapping
.name
, 'a')
363 if mapping
.lower
== 0 and mapping
.upper
== 0:
365 elif mapping
.lower
== 5 and mapping
.upper
== 5:
367 elif mapping
.lower
== 17 and mapping
.upper
== 144:
370 self
.assertEqual(i
, 3)
373 self
.assertTrue(a17_144
)
375 def test_find_by_name_signed(self
):
376 self
._test
_find
_by
_name
(bt2
.EnumerationFieldClass(size
=8, is_signed
=True))
378 def test_find_by_name_unsigned(self
):
379 self
._test
_find
_by
_name
(bt2
.EnumerationFieldClass(size
=8))
381 def _test_find_by_value(self
, fc
):
382 fc
.add_mapping('a', 0)
383 fc
.add_mapping('b', 1, 3)
384 fc
.add_mapping('c', 5, 19)
385 fc
.add_mapping('d', 8, 15)
386 fc
.add_mapping('e', 10, 21)
387 fc
.add_mapping('f', 0)
388 fc
.add_mapping('g', 14)
389 mapping_iter
= fc
.mappings_by_value(14)
390 mappings
= list(mapping_iter
)
397 for mapping
in mappings
:
400 if mapping
.name
== 'c':
402 elif mapping
.name
== 'd':
404 elif mapping
.name
== 'e':
406 elif mapping
.name
== 'g':
409 self
.assertEqual(i
, 4)
415 def test_find_by_value_signed(self
):
416 self
._test
_find
_by
_value
(bt2
.EnumerationFieldClass(size
=8, is_signed
=True))
418 def test_find_by_value_unsigned(self
):
419 self
._test
_find
_by
_value
(bt2
.EnumerationFieldClass(size
=8))
421 def test_create_field(self
):
422 self
._fc
.add_mapping('c', 4, 5)
424 self
.assertIsInstance(field
, bt2
.field
._EnumerationField
)
426 def test_create_field_init(self
):
427 self
._fc
.add_mapping('c', 4, 5)
429 self
.assertEqual(field
, 4)
432 @unittest.skip("this is broken")
433 class StringFieldClassTestCase(_TestCopySimple
, _TestInvalidEq
,
436 self
._fc
= bt2
.StringFieldClass()
441 def test_create_default(self
):
444 def test_create_full(self
):
445 fc
= bt2
.StringFieldClass(encoding
=bt2
.Encoding
.UTF8
)
446 self
.assertEqual(fc
.encoding
, bt2
.Encoding
.UTF8
)
448 def test_assign_encoding(self
):
449 self
._fc
.encoding
= bt2
.Encoding
.UTF8
450 self
.assertEqual(self
._fc
.encoding
, bt2
.Encoding
.UTF8
)
452 def test_assign_invalid_encoding(self
):
453 with self
.assertRaises(TypeError):
454 self
._fc
.encoding
= 'yes'
456 def test_create_field(self
):
458 self
.assertIsInstance(field
, bt2
.field
._StringField
)
460 def test_create_field_init(self
):
461 field
= self
._fc
('hola')
462 self
.assertEqual(field
, 'hola')
465 class _TestFieldContainer(_TestInvalidEq
, _TestCopySimple
):
466 def test_append_field(self
):
467 int_field_class
= bt2
.IntegerFieldClass(32)
468 self
._fc
.append_field('int32', int_field_class
)
469 field_class
= self
._fc
['int32']
470 self
.assertEqual(field_class
, int_field_class
)
472 def test_append_field_kwargs(self
):
473 int_field_class
= bt2
.IntegerFieldClass(32)
474 self
._fc
.append_field(name
='int32', field_class
=int_field_class
)
475 field_class
= self
._fc
['int32']
476 self
.assertEqual(field_class
, int_field_class
)
478 def test_append_field_invalid_name(self
):
479 with self
.assertRaises(TypeError):
480 self
._fc
.append_field(23, bt2
.StringFieldClass())
482 def test_append_field_invalid_field_class(self
):
483 with self
.assertRaises(TypeError):
484 self
._fc
.append_field('yes', object())
487 struct_fc
= bt2
.StructureFieldClass()
488 c_field_class
= bt2
.StringFieldClass()
489 d_field_class
= bt2
.EnumerationFieldClass(size
=32)
490 e_field_class
= bt2
.StructureFieldClass()
491 struct_fc
.append_field('c_string', c_field_class
)
492 struct_fc
.append_field('d_enum', d_field_class
)
493 struct_fc
.append_field('e_struct', e_field_class
)
494 a_field_class
= bt2
.FloatingPointNumberFieldClass()
495 b_field_class
= bt2
.IntegerFieldClass(17)
496 self
._fc
.append_field('a_float', a_field_class
)
497 self
._fc
.append_field('b_int', b_field_class
)
498 self
._fc
+= struct_fc
499 self
.assertEqual(self
._fc
['a_float'], a_field_class
)
500 self
.assertEqual(self
._fc
['b_int'], b_field_class
)
501 self
.assertEqual(self
._fc
['c_string'], c_field_class
)
502 self
.assertEqual(self
._fc
['d_enum'], d_field_class
)
503 self
.assertEqual(self
._fc
['e_struct'], e_field_class
)
505 def test_bool_op(self
):
506 self
.assertFalse(self
._fc
)
507 self
._fc
.append_field('a', bt2
.StringFieldClass())
508 self
.assertTrue(self
._fc
)
511 fc
= bt2
.StringFieldClass()
512 self
._fc
.append_field('a', fc
)
513 self
._fc
.append_field('b', fc
)
514 self
._fc
.append_field('c', fc
)
515 self
.assertEqual(len(self
._fc
), 3)
517 def test_getitem(self
):
518 a_fc
= bt2
.IntegerFieldClass(32)
519 b_fc
= bt2
.StringFieldClass()
520 c_fc
= bt2
.FloatingPointNumberFieldClass()
521 self
._fc
.append_field('a', a_fc
)
522 self
._fc
.append_field('b', b_fc
)
523 self
._fc
.append_field('c', c_fc
)
524 self
.assertEqual(self
._fc
['b'], b_fc
)
526 def test_getitem_invalid_key_type(self
):
527 with self
.assertRaises(TypeError):
530 def test_getitem_invalid_key(self
):
531 with self
.assertRaises(KeyError):
534 def test_contains(self
):
535 self
.assertFalse('a' in self
._fc
)
536 self
._fc
.append_field('a', bt2
.StringFieldClass())
537 self
.assertTrue('a' in self
._fc
)
540 a_fc
= bt2
.IntegerFieldClass(32)
541 b_fc
= bt2
.StringFieldClass()
542 c_fc
= bt2
.FloatingPointNumberFieldClass()
550 self
._fc
.append_field(*field
)
552 for (name
, fc_field_class
), field
in zip(self
._fc
.items(), fields
):
553 self
.assertEqual(name
, field
[0])
554 self
.assertEqual(fc_field_class
, field
[1])
556 def test_at_index(self
):
557 a_fc
= bt2
.IntegerFieldClass(32)
558 b_fc
= bt2
.StringFieldClass()
559 c_fc
= bt2
.FloatingPointNumberFieldClass()
560 self
._fc
.append_field('c', c_fc
)
561 self
._fc
.append_field('a', a_fc
)
562 self
._fc
.append_field('b', b_fc
)
563 self
.assertEqual(self
._fc
.at_index(1), a_fc
)
565 def test_at_index_invalid(self
):
566 self
._fc
.append_field('c', bt2
.IntegerFieldClass(32))
568 with self
.assertRaises(TypeError):
569 self
._fc
.at_index('yes')
571 def test_at_index_out_of_bounds_after(self
):
572 self
._fc
.append_field('c', bt2
.IntegerFieldClass(32))
574 with self
.assertRaises(IndexError):
575 self
._fc
.at_index(len(self
._fc
))
578 @unittest.skip("this is broken")
579 class StructureFieldClassTestCase(_TestFieldContainer
, unittest
.TestCase
):
581 self
._fc
= bt2
.StructureFieldClass()
586 def test_create_default(self
):
587 self
.assertEqual(self
._fc
.alignment
, 1)
589 def test_create_with_min_alignment(self
):
590 fc
= bt2
.StructureFieldClass(8)
591 self
.assertEqual(fc
.alignment
, 8)
593 def test_assign_alignment(self
):
594 with self
.assertRaises(AttributeError):
595 self
._fc
.alignment
= 32
597 def test_assign_min_alignment(self
):
598 self
._fc
.min_alignment
= 64
599 self
.assertTrue(self
._fc
.alignment
>= 64)
601 def test_assign_invalid_min_alignment(self
):
602 with self
.assertRaises(ValueError):
603 self
._fc
.min_alignment
= 23
605 def test_assign_get_min_alignment(self
):
606 with self
.assertRaises(AttributeError):
607 self
._fc
.min_alignment
609 def test_create_field(self
):
611 self
.assertIsInstance(field
, bt2
.field
._StructureField
)
613 def test_create_field_init_invalid(self
):
614 with self
.assertRaises(bt2
.Error
):
618 @unittest.skip("this is broken")
619 class VariantFieldClassTestCase(_TestFieldContainer
, unittest
.TestCase
):
621 self
._fc
= bt2
.VariantFieldClass('path.to.tag')
626 def test_create_default(self
):
627 self
.assertEqual(self
._fc
.tag_name
, 'path.to.tag')
629 def test_create_invalid_tag_name(self
):
630 with self
.assertRaises(TypeError):
631 self
._fc
= bt2
.VariantFieldClass(23)
633 def test_assign_tag_name(self
):
634 self
._fc
.tag_name
= 'a.different.tag'
635 self
.assertEqual(self
._fc
.tag_name
, 'a.different.tag')
637 def test_assign_invalid_tag_name(self
):
638 with self
.assertRaises(TypeError):
639 self
._fc
.tag_name
= -17
642 @unittest.skip("this is broken")
643 class ArrayFieldClassTestCase(_TestInvalidEq
, _TestCopySimple
,
646 self
._elem
_fc
= bt2
.IntegerFieldClass(23)
647 self
._fc
= bt2
.ArrayFieldClass(self
._elem
_fc
, 45)
653 def test_create_default(self
):
654 self
.assertEqual(self
._fc
.element_field_class
, self
._elem
_fc
)
655 self
.assertEqual(self
._fc
.length
, 45)
657 def test_create_invalid_field_class(self
):
658 with self
.assertRaises(TypeError):
659 self
._fc
= bt2
.ArrayFieldClass(object(), 45)
661 def test_create_invalid_length(self
):
662 with self
.assertRaises(ValueError):
663 self
._fc
= bt2
.ArrayFieldClass(bt2
.StringFieldClass(), -17)
665 def test_create_invalid_length_type(self
):
666 with self
.assertRaises(TypeError):
667 self
._fc
= bt2
.ArrayFieldClass(bt2
.StringFieldClass(), 'the length')
669 def test_create_field(self
):
671 self
.assertIsInstance(field
, bt2
.field
._ArrayField
)
673 def test_create_field_init_invalid(self
):
674 with self
.assertRaises(bt2
.Error
):
678 @unittest.skip("this is broken")
679 class SequenceFieldClassTestCase(_TestInvalidEq
, _TestCopySimple
,
682 self
._elem
_fc
= bt2
.IntegerFieldClass(23)
683 self
._fc
= bt2
.SequenceFieldClass(self
._elem
_fc
, 'the.length')
689 def test_create_default(self
):
690 self
.assertEqual(self
._fc
.element_field_class
, self
._elem
_fc
)
691 self
.assertEqual(self
._fc
.length_name
, 'the.length')
693 def test_create_invalid_field_class(self
):
694 with self
.assertRaises(TypeError):
695 self
._fc
= bt2
.ArrayFieldClass(object(), 'the.length')
697 def test_create_invalid_length_type(self
):
698 with self
.assertRaises(TypeError):
699 self
._fc
= bt2
.SequenceFieldClass(bt2
.StringFieldClass(), 17)
701 def test_create_field(self
):
703 self
.assertIsInstance(field
, bt2
.field
._SequenceField
)
705 def test_create_field_init_invalid(self
):
706 with self
.assertRaises(bt2
.Error
):