3 from clang
.cindex
import (
8 ExceptionSpecificationKind
,
19 class TestEnums(unittest
.TestCase
):
24 ExceptionSpecificationKind
,
35 def test_from_id(self
):
36 """Check that kinds can be constructed from valid IDs"""
37 for enum
in self
.enums
:
38 self
.assertEqual(enum
.from_id(2), enum(2))
39 max_value
= max([variant
.value
for variant
in enum
])
40 with self
.assertRaises(ValueError):
41 enum
.from_id(max_value
+ 1)
42 with self
.assertRaises(ValueError):
45 def test_duplicate_ids(self
):
46 """Check that no two kinds have the same id"""
47 # for enum in self.enums:
48 for enum
in self
.enums
:
49 num_declared_variants
= len(enum
._member
_map
_.keys())
50 num_unique_variants
= len(list(enum
))
51 self
.assertEqual(num_declared_variants
, num_unique_variants
)