summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-03-06 19:37:38 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-24 15:37:20 (GMT)
commit4c2326f24a266c2ee7b88b50c5655fb2edbd082c (patch)
treee7fb3ec83ebc53519472a59dfab253bfbc8ebb17 /test
parentdc4d4e2dcdbf6464c864d7fa49e2da3a04cd3e76 (diff)
downloadCastXML-4c2326f24a266c2ee7b88b50c5655fb2edbd082c.zip
CastXML-4c2326f24a266c2ee7b88b50c5655fb2edbd082c.tar.gz
CastXML-4c2326f24a266c2ee7b88b50c5655fb2edbd082c.tar.bz2
test: Add cases for C-mode gccxml-like output
Although gccxml did not support C, it was occasionally requested. The gccxml output format supports C and Clang can easily handle parsing it. Add test cases that verify Clang can parse sources as C code and not C++.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt5
-rw-r--r--test/expect/gccxml.c.FundamentalType-xml.txt7
-rw-r--r--test/expect/gccxml.c.Typedef-called-class-xml.txt8
-rw-r--r--test/expect/gccxml.c.invalid-result.txt1
-rw-r--r--test/expect/gccxml.c.invalid-stderr.txt1
-rw-r--r--test/input/FundamentalType.c1
-rw-r--r--test/input/Typedef-called-class.c2
-rw-r--r--test/input/invalid.c1
8 files changed, 26 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e1b3c12..d3cb069 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -116,3 +116,8 @@ castxml_test_gccxml(using-declaration-ns)
castxml_test_gccxml(using-declaration-start)
castxml_test_gccxml(using-directive-ns)
castxml_test_gccxml(using-directive-start)
+
+castxml_test_gccxml_c(FundamentalType)
+castxml_test_gccxml_c(Typedef-called-class)
+
+castxml_test_gccxml_c(invalid)
diff --git a/test/expect/gccxml.c.FundamentalType-xml.txt b/test/expect/gccxml.c.FundamentalType-xml.txt
new file mode 100644
index 0000000..6fe4c46
--- /dev/null
+++ b/test/expect/gccxml.c.FundamentalType-xml.txt
@@ -0,0 +1,7 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Typedef id="_1" name="start" type="_2" context="_3" location="f1:1" file="f1" line="1"/>
+ <FundamentalType id="_2" name="int"/>
+ <Namespace id="_3" name="::"/>
+ <File id="f1" name=".*/test/input/FundamentalType.c"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.c.Typedef-called-class-xml.txt b/test/expect/gccxml.c.Typedef-called-class-xml.txt
new file mode 100644
index 0000000..023418e
--- /dev/null
+++ b/test/expect/gccxml.c.Typedef-called-class-xml.txt
@@ -0,0 +1,8 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Typedef id="_1" name="start" type="_2" context="_3" location="f1:2" file="f1" line="2"/>
+ <Typedef id="_2" name="class" type="_4" context="_3" location="f1:1" file="f1" line="1"/>
+ <FundamentalType id="_4" name="int"/>
+ <Namespace id="_3" name="::"/>
+ <File id="f1" name=".*/test/input/Typedef-called-class.c"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.c.invalid-result.txt b/test/expect/gccxml.c.invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/expect/gccxml.c.invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/test/expect/gccxml.c.invalid-stderr.txt b/test/expect/gccxml.c.invalid-stderr.txt
new file mode 100644
index 0000000..73c9062
--- /dev/null
+++ b/test/expect/gccxml.c.invalid-stderr.txt
@@ -0,0 +1 @@
+error: unknown type name 'class'
diff --git a/test/input/FundamentalType.c b/test/input/FundamentalType.c
new file mode 100644
index 0000000..ed6c3c8
--- /dev/null
+++ b/test/input/FundamentalType.c
@@ -0,0 +1 @@
+typedef int start;
diff --git a/test/input/Typedef-called-class.c b/test/input/Typedef-called-class.c
new file mode 100644
index 0000000..a5b9ca3
--- /dev/null
+++ b/test/input/Typedef-called-class.c
@@ -0,0 +1,2 @@
+typedef int class;
+typedef class start;
diff --git a/test/input/invalid.c b/test/input/invalid.c
new file mode 100644
index 0000000..2e739ef
--- /dev/null
+++ b/test/input/invalid.c
@@ -0,0 +1 @@
+class start;