xref: /openbsd-src/gnu/llvm/clang/bindings/python/tests/cindex/test_index.py (revision e5dd70708596ae51455a0ffa086a00c5b29f8583)
1*e5dd7070Spatrickimport os
2*e5dd7070Spatrickfrom clang.cindex import Config
3*e5dd7070Spatrickif 'CLANG_LIBRARY_PATH' in os.environ:
4*e5dd7070Spatrick    Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
5*e5dd7070Spatrick
6*e5dd7070Spatrickfrom clang.cindex import *
7*e5dd7070Spatrickimport os
8*e5dd7070Spatrickimport unittest
9*e5dd7070Spatrick
10*e5dd7070Spatrick
11*e5dd7070SpatrickkInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
12*e5dd7070Spatrick
13*e5dd7070Spatrick
14*e5dd7070Spatrickclass TestIndex(unittest.TestCase):
15*e5dd7070Spatrick    def test_create(self):
16*e5dd7070Spatrick        index = Index.create()
17*e5dd7070Spatrick
18*e5dd7070Spatrick    # FIXME: test Index.read
19*e5dd7070Spatrick
20*e5dd7070Spatrick    def test_parse(self):
21*e5dd7070Spatrick        index = Index.create()
22*e5dd7070Spatrick        self.assertIsInstance(index, Index)
23*e5dd7070Spatrick        tu = index.parse(os.path.join(kInputsDir, 'hello.cpp'))
24*e5dd7070Spatrick        self.assertIsInstance(tu, TranslationUnit)
25*e5dd7070Spatrick        tu = index.parse(None, ['-c', os.path.join(kInputsDir, 'hello.cpp')])
26*e5dd7070Spatrick        self.assertIsInstance(tu, TranslationUnit)
27