]> granicus.if.org Git - clang/commitdiff
Re-add clang-format tests to clang/test.
authorDaniel Jasper <djasper@google.com>
Mon, 25 Mar 2013 09:14:25 +0000 (09:14 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 25 Mar 2013 09:14:25 +0000 (09:14 +0000)
Also now use -strict-whitespace as the tests are confusing otherwise.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177853 91177308-0d34-0410-b5e6-96231b3b80d8

test/CMakeLists.txt
test/Format/basic.cpp [new file with mode: 0644]
test/Format/diagnostic.cpp [new file with mode: 0644]
test/Format/ranges.cpp [new file with mode: 0644]

index 114015bfe0bbe21979bd13e9ebc4cac7a8ae78bd..a11b83a854cb0d1bfed4b633a90b823974a43234 100644 (file)
@@ -29,7 +29,7 @@ endif ()
 set(CLANG_TEST_DEPS
   clang clang-headers
   c-index-test diagtool arcmt-test c-arcmt-test
-  clang-check
+  clang-check clang-format
   )
 set(CLANG_TEST_PARAMS
   clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
diff --git a/test/Format/basic.cpp b/test/Format/basic.cpp
new file mode 100644 (file)
index 0000000..375bbd2
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-format -i %t.cpp
+// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+
+// CHECK: {{^int\ \*i;}}
+ int   *  i  ;
diff --git a/test/Format/diagnostic.cpp b/test/Format/diagnostic.cpp
new file mode 100644 (file)
index 0000000..2e930ee
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: clang-format 2>&1 >/dev/null %s |FileCheck %s
+
+}
+// CHECK: diagnostic.cpp:[[@LINE-1]]:1: error: unexpected '}'
diff --git a/test/Format/ranges.cpp b/test/Format/ranges.cpp
new file mode 100644 (file)
index 0000000..0244fc1
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-format -offset=2 -length=0 -offset=28 -length=0 -i %t.cpp
+// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// CHECK: {{^int\ \*i;$}}
+  int*i;
+
+// CHECK: {{^\ \ int\ \ \*\ \ i;$}}
+  int  *  i; 
+
+// CHECK: {{^\ \ int\ \*i;$}}
+  int   *   i;