From fe04fe0d41963735c8065eb2f547a3a08ef81810 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 7 Oct 2013 16:38:40 +0000 Subject: [PATCH] =?UTF-8?q?[libclang]=20Add=20some=20tests=20by=20Lo=C3=AF?= =?UTF-8?q?c=20Jaquemet=20that=20I=20forgot=20to=20add=20earlier.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llvm-svn: 192108 --- .../python/tests/cindex/test_comment.py | 40 +++++++++++++++++++ clang/test/Index/attributes.c | 10 +++++ 2 files changed, 50 insertions(+) create mode 100644 clang/bindings/python/tests/cindex/test_comment.py create mode 100644 clang/test/Index/attributes.c diff --git a/clang/bindings/python/tests/cindex/test_comment.py b/clang/bindings/python/tests/cindex/test_comment.py new file mode 100644 index 000000000000..d8f3129ac51e --- /dev/null +++ b/clang/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 + + diff --git a/clang/test/Index/attributes.c b/clang/test/Index/attributes.c new file mode 100644 index 000000000000..3e60e6c0e495 --- /dev/null +++ b/clang/test/Index/attributes.c @@ -0,0 +1,10 @@ +// RUN: c-index-test -test-load-source all %s | FileCheck %s + +struct __attribute__((packed)) Test2 { + char a; +}; + +// CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 5:2] +// CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29] +// CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] [access=public] +