summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-10-07 16:38:40 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-10-07 16:38:40 +0000
commitb73479e9b23403987c9b358ed7cd42afa17f9fa4 (patch)
tree9a6f5d9515fe137ac67fef31039d1464bbc873f3 /bindings
parent2815d9c9989c52ac9c5687253bc544fac9d32c7f (diff)
[libclang] Add some tests by Loïc Jaquemet that I forgot to add earlier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192108 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/tests/cindex/test_comment.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/bindings/python/tests/cindex/test_comment.py b/bindings/python/tests/cindex/test_comment.py
new file mode 100644
index 0000000000..d8f3129ac5
--- /dev/null
+++ b/bindings/python/tests/cindex/test_comment.py
@@ -0,0 +1,40 @@
+from clang.cindex import TranslationUnit
+from tests.cindex.util import get_cursor
+
+def test_comment():
+ files = [('fake.c', """
+/// Aaa.
+int test1;
+
+/// Bbb.
+/// x
+void test2(void);
+
+void f() {
+
+}
+""")]
+ # make a comment-aware TU
+ tu = TranslationUnit.from_source('fake.c', ['-std=c99'], unsaved_files=files,
+ options=TranslationUnit.PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETION)
+ test1 = get_cursor(tu, 'test1')
+ assert test1 is not None, "Could not find test1."
+ assert test1.type.is_pod()
+ raw = test1.raw_comment
+ brief = test1.brief_comment
+ assert raw == """/// Aaa."""
+ assert brief == """Aaa."""
+
+ test2 = get_cursor(tu, 'test2')
+ raw = test2.raw_comment
+ brief = test2.brief_comment
+ assert raw == """/// Bbb.\n/// x"""
+ assert brief == """Bbb. x"""
+
+ f = get_cursor(tu, 'f')
+ raw = f.raw_comment
+ brief = f.brief_comment
+ assert raw is None
+ assert brief is None
+
+