Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / bindings / python / tests / cindex / test_access_specifiers.py
blobc1cc18ebe6e5896b51834595c63df648b2c38407
1 import os
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 AccessSpecifier
8 from clang.cindex import Cursor
9 from clang.cindex import TranslationUnit
11 from .util import get_cursor
12 from .util import get_tu
14 import unittest
17 class TestAccessSpecifiers(unittest.TestCase):
18 def test_access_specifiers(self):
19 """Ensure that C++ access specifiers are available on cursors"""
21 tu = get_tu(
22 """
23 class test_class {
24 public:
25 void public_member_function();
26 protected:
27 void protected_member_function();
28 private:
29 void private_member_function();
31 """,
32 lang="cpp",
35 test_class = get_cursor(tu, "test_class")
36 self.assertEqual(test_class.access_specifier, AccessSpecifier.INVALID)
38 public = get_cursor(tu.cursor, "public_member_function")
39 self.assertEqual(public.access_specifier, AccessSpecifier.PUBLIC)
41 protected = get_cursor(tu.cursor, "protected_member_function")
42 self.assertEqual(protected.access_specifier, AccessSpecifier.PROTECTED)
44 private = get_cursor(tu.cursor, "private_member_function")
45 self.assertEqual(private.access_specifier, AccessSpecifier.PRIVATE)