aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/Format/basic.cpp6
-rw-r--r--test/Format/diagnostic.cpp4
-rw-r--r--test/Format/ranges.cpp11
4 files changed, 22 insertions, 1 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 114015bfe0..a11b83a854 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -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
index 0000000000..375bbd2ec7
--- /dev/null
+++ b/test/Format/basic.cpp
@@ -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
index 0000000000..2e930ee5b7
--- /dev/null
+++ b/test/Format/diagnostic.cpp
@@ -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
index 0000000000..0244fc195c
--- /dev/null
+++ b/test/Format/ranges.cpp
@@ -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;