[clang] [libclang/python] Improve test coverage (PR #109846)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 13:01:37 PDT 2024
================
@@ -357,6 +359,50 @@ def test_is_restrict_qualified(self):
self.assertTrue(i.type.is_restrict_qualified())
self.assertFalse(j.type.is_restrict_qualified())
+ def test_get_result(self):
+ tu = get_tu("void foo(); int bar(char, short);")
+ foo = get_cursor(tu, "foo")
+ bar = get_cursor(tu, "bar")
+ self.assertEqual(foo.type.get_result().spelling, "void")
+ self.assertEqual(bar.type.get_result().spelling, "int")
+
+ def test_get_class_type(self):
+ tu = get_tu(
+ """
+class myClass
+{
+ char *myAttr;
+};
+
+char *myClass::*pMyAttr = &myClass::myAttr;
+""",
+ lang="cpp",
+ )
+ cur = get_cursor(tu, "pMyAttr")
+ self.assertEqual(cur.type.get_class_type().spelling, "myClass")
+
+ def test_get_named_type(self):
+ tu = get_tu("using char_alias = char; char_alias xyz;", lang="cpp")
+ cur = get_cursor(tu, "xyz")
+ self.assertEqual(cur.type.kind, TypeKind.ELABORATED)
+ self.assertEqual(cur.type.get_named_type().spelling, "char_alias")
----------------
DeinAlptraum wrote:
Does that mean I should just remove the `self.assertEqual(cur.type.kind, TypeKind.ELABORATED)`, or what exactly?
https://github.com/llvm/llvm-project/pull/109846
More information about the cfe-commits
mailing list