diff options
Diffstat (limited to 'bindings/python/tests')
-rw-r--r-- | bindings/python/tests/cindex/INPUTS/header1.h | 6 | ||||
-rw-r--r-- | bindings/python/tests/cindex/INPUTS/header2.h | 6 | ||||
-rw-r--r-- | bindings/python/tests/cindex/INPUTS/header3.h | 3 | ||||
-rw-r--r-- | bindings/python/tests/cindex/INPUTS/include.cpp | 5 | ||||
-rw-r--r-- | bindings/python/tests/cindex/test_translation_unit.py | 22 |
5 files changed, 42 insertions, 0 deletions
diff --git a/bindings/python/tests/cindex/INPUTS/header1.h b/bindings/python/tests/cindex/INPUTS/header1.h new file mode 100644 index 0000000000..b4eacbee37 --- /dev/null +++ b/bindings/python/tests/cindex/INPUTS/header1.h @@ -0,0 +1,6 @@ +#ifndef HEADER1 +#define HEADER1 + +#include "header3.h" + +#endif diff --git a/bindings/python/tests/cindex/INPUTS/header2.h b/bindings/python/tests/cindex/INPUTS/header2.h new file mode 100644 index 0000000000..c4eddc0c56 --- /dev/null +++ b/bindings/python/tests/cindex/INPUTS/header2.h @@ -0,0 +1,6 @@ +#ifndef HEADER2 +#define HEADER2 + +#include "header3.h" + +#endif diff --git a/bindings/python/tests/cindex/INPUTS/header3.h b/bindings/python/tests/cindex/INPUTS/header3.h new file mode 100644 index 0000000000..6dca764860 --- /dev/null +++ b/bindings/python/tests/cindex/INPUTS/header3.h @@ -0,0 +1,3 @@ +// Not a guarded header! + +void f(); diff --git a/bindings/python/tests/cindex/INPUTS/include.cpp b/bindings/python/tests/cindex/INPUTS/include.cpp new file mode 100644 index 0000000000..60cfdaae4d --- /dev/null +++ b/bindings/python/tests/cindex/INPUTS/include.cpp @@ -0,0 +1,5 @@ +#include "header1.h" +#include "header2.h" +#include "header1.h" + +int main() { } diff --git a/bindings/python/tests/cindex/test_translation_unit.py b/bindings/python/tests/cindex/test_translation_unit.py index ec12e689d9..3c05c3f06a 100644 --- a/bindings/python/tests/cindex/test_translation_unit.py +++ b/bindings/python/tests/cindex/test_translation_unit.py @@ -49,3 +49,25 @@ def test_unsaved_files_2(): ('fake.c', StringIO.StringIO('int x;'))]) spellings = [c.spelling for c in tu.cursor.get_children()] assert spellings[-1] == 'x' + + +def test_includes(): + def eq(expected, actual): + if not actual.is_input_file: + return expected[0] == actual.source.name and \ + expected[1] == actual.include.name + else: + return expected[1] == actual.include.name + + src = os.path.join(kInputsDir, 'include.cpp') + h1 = os.path.join(kInputsDir, "header1.h") + h2 = os.path.join(kInputsDir, "header2.h") + h3 = os.path.join(kInputsDir, "header3.h") + inc = [(None, src), (src, h1), (h1, h3), (src, h2), (h2, h3)] + + index = Index.create() + tu = index.parse(src) + for i in zip(inc, tu.get_includes()): + assert eq(i[0], i[1]) + + |