1 from clang.cindex import CursorKind 2 3 def test_name(): 4 assert CursorKind.UNEXPOSED_DECL.name is 'UNEXPOSED_DECL' 5 6 def test_get_all_kinds(): 7 assert CursorKind.UNEXPOSED_DECL in CursorKind.get_all_kinds() 8 assert CursorKind.TRANSLATION_UNIT in CursorKind.get_all_kinds() 9 10 def test_kind_groups(): 11 """Check that every kind classifies to exactly one group.""" 12 13 assert CursorKind.UNEXPOSED_DECL.is_declaration() 14 assert CursorKind.TYPE_REF.is_reference() 15 assert CursorKind.DECL_REF_EXPR.is_expression() 16 assert CursorKind.UNEXPOSED_STMT.is_statement() 17 assert CursorKind.INVALID_FILE.is_invalid() 18 19 for k in CursorKind.get_all_kinds(): 20 group = [n for n in ('is_declaration', 'is_reference', 'is_expression', 21 'is_statement', 'is_invalid', 'is_attribute') 22 if getattr(k, n)()] 23 24 if k in ( CursorKind.TRANSLATION_UNIT, 25 CursorKind.MACRO_DEFINITION, 26 CursorKind.MACRO_INSTANTIATION, 27 CursorKind.INCLUSION_DIRECTIVE, 28 CursorKind.PREPROCESSING_DIRECTIVE): 29 assert len(group) == 0 30 else: 31 assert len(group) == 1 32