Home | History | Annotate | Download | only in cindex
      1 
      2 from clang.cindex import AccessSpecifier
      3 from clang.cindex import Cursor
      4 from clang.cindex import TranslationUnit
      5 
      6 from .util import get_cursor
      7 from .util import get_tu
      8 
      9 def test_access_specifiers():
     10     """Ensure that C++ access specifiers are available on cursors"""
     11 
     12     tu = get_tu("""
     13 class test_class {
     14 public:
     15   void public_member_function();
     16 protected:
     17   void protected_member_function();
     18 private:
     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