diff options
Diffstat (limited to 'bindings/python/tests/cindex/test_type.py')
-rw-r--r-- | bindings/python/tests/cindex/test_type.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py index 4dec0583c7b0..bcdbeff9d99c 100644 --- a/bindings/python/tests/cindex/test_type.py +++ b/bindings/python/tests/cindex/test_type.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + import gc import unittest @@ -436,3 +441,28 @@ class TestType(unittest.TestCase): self.assertIsNotNone(testInteger, "Could not find testInteger.") self.assertEqual(testInteger.type.get_address_space(), 2) + + def test_template_arguments(self): + source = """ + class Foo { + }; + template <typename T> + class Template { + }; + Template<Foo> instance; + int bar; + """ + tu = get_tu(source, lang='cpp') + + # Varible with a template argument. + cursor = get_cursor(tu, 'instance') + cursor_type = cursor.type + self.assertEqual(cursor.kind, CursorKind.VAR_DECL) + self.assertEqual(cursor_type.spelling, 'Template<Foo>') + self.assertEqual(cursor_type.get_num_template_arguments(), 1) + template_type = cursor_type.get_template_argument_type(0) + self.assertEqual(template_type.spelling, 'Foo') + + # Variable without a template argument. + cursor = get_cursor(tu, 'bar') + self.assertEqual(cursor.get_num_template_arguments(), -1) |