2 from clang
.cindex
import Config
4 if "CLANG_LIBRARY_PATH" in os
.environ
:
5 Config
.set_library_path(os
.environ
["CLANG_LIBRARY_PATH"])
7 from clang
.cindex
import CursorKind
12 class TestCursorKind(unittest
.TestCase
):
14 self
.assertEqual(CursorKind
.UNEXPOSED_DECL
.name
, "UNEXPOSED_DECL")
16 def test_get_all_kinds(self
):
17 kinds
= CursorKind
.get_all_kinds()
18 self
.assertIn(CursorKind
.UNEXPOSED_DECL
, kinds
)
19 self
.assertIn(CursorKind
.TRANSLATION_UNIT
, kinds
)
20 self
.assertIn(CursorKind
.VARIABLE_REF
, kinds
)
21 self
.assertIn(CursorKind
.LAMBDA_EXPR
, kinds
)
22 self
.assertIn(CursorKind
.OBJ_BOOL_LITERAL_EXPR
, kinds
)
23 self
.assertIn(CursorKind
.OBJ_SELF_EXPR
, kinds
)
24 self
.assertIn(CursorKind
.MS_ASM_STMT
, kinds
)
25 self
.assertIn(CursorKind
.MODULE_IMPORT_DECL
, kinds
)
26 self
.assertIn(CursorKind
.TYPE_ALIAS_TEMPLATE_DECL
, kinds
)
28 def test_kind_groups(self
):
29 """Check that every kind classifies to exactly one group."""
31 self
.assertTrue(CursorKind
.UNEXPOSED_DECL
.is_declaration())
32 self
.assertTrue(CursorKind
.TYPE_REF
.is_reference())
33 self
.assertTrue(CursorKind
.DECL_REF_EXPR
.is_expression())
34 self
.assertTrue(CursorKind
.UNEXPOSED_STMT
.is_statement())
35 self
.assertTrue(CursorKind
.INVALID_FILE
.is_invalid())
37 self
.assertTrue(CursorKind
.TRANSLATION_UNIT
.is_translation_unit())
38 self
.assertFalse(CursorKind
.TYPE_REF
.is_translation_unit())
40 self
.assertTrue(CursorKind
.PREPROCESSING_DIRECTIVE
.is_preprocessing())
41 self
.assertFalse(CursorKind
.TYPE_REF
.is_preprocessing())
43 self
.assertTrue(CursorKind
.UNEXPOSED_DECL
.is_unexposed())
44 self
.assertFalse(CursorKind
.TYPE_REF
.is_unexposed())
46 for k
in CursorKind
.get_all_kinds():
61 CursorKind
.TRANSLATION_UNIT
,
62 CursorKind
.MACRO_DEFINITION
,
63 CursorKind
.MACRO_INSTANTIATION
,
64 CursorKind
.INCLUSION_DIRECTIVE
,
65 CursorKind
.PREPROCESSING_DIRECTIVE
,
66 CursorKind
.OVERLOAD_CANDIDATE
,
68 self
.assertEqual(len(group
), 0)
70 self
.assertEqual(len(group
), 1)