• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2from clang.cindex import AccessSpecifier
3from clang.cindex import Cursor
4from clang.cindex import TranslationUnit
5
6from .util import get_cursor
7from .util import get_tu
8
9def test_access_specifiers():
10    """Ensure that C++ access specifiers are available on cursors"""
11
12    tu = get_tu("""
13class test_class {
14public:
15  void public_member_function();
16protected:
17  void protected_member_function();
18private:
19  void private_member_function();
20};
21""", lang = 'cpp')
22
23    test_class = get_cursor(tu, "test_class")
24    assert test_class.access_specifier == AccessSpecifier.INVALID;
25
26    public = get_cursor(tu.cursor, "public_member_function")
27    assert public.access_specifier == AccessSpecifier.PUBLIC
28
29    protected = get_cursor(tu.cursor, "protected_member_function")
30    assert protected.access_specifier == AccessSpecifier.PROTECTED
31
32    private = get_cursor(tu.cursor, "private_member_function")
33    assert private.access_specifier == AccessSpecifier.PRIVATE
34
35