diff options
Diffstat (limited to 'test/Format')
-rw-r--r-- | test/Format/adjust-indent.cpp | 10 | ||||
-rw-r--r-- | test/Format/basic.cpp | 5 | ||||
-rw-r--r-- | test/Format/cursor.cpp | 7 | ||||
-rw-r--r-- | test/Format/disable-format.cpp | 5 | ||||
-rw-r--r-- | test/Format/disable-include-sorting.cpp | 10 | ||||
-rw-r--r-- | test/Format/incomplete.cpp | 5 | ||||
-rw-r--r-- | test/Format/language-detection.cpp | 10 | ||||
-rw-r--r-- | test/Format/line-ranges.cpp | 14 | ||||
-rw-r--r-- | test/Format/ranges.cpp | 16 | ||||
-rw-r--r-- | test/Format/style-on-command-line.cpp | 19 | ||||
-rw-r--r-- | test/Format/xmloutput.cpp | 12 |
11 files changed, 71 insertions, 42 deletions
diff --git a/test/Format/adjust-indent.cpp b/test/Format/adjust-indent.cpp new file mode 100644 index 0000000..5565dc0 --- /dev/null +++ b/test/Format/adjust-indent.cpp @@ -0,0 +1,10 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -lines=2:2 \ +// RUN: | FileCheck -strict-whitespace %s + +void f() { +// CHECK: void f() { +int i; +// CHECK: {{^ int\ i;}} + int j; +// CHECK: {{^ int\ j;}} +} diff --git a/test/Format/basic.cpp b/test/Format/basic.cpp index a12866b..e92291d 100644 --- a/test/Format/basic.cpp +++ b/test/Format/basic.cpp @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-format -style=LLVM -i %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{^int\ \*i;}} int * i ; diff --git a/test/Format/cursor.cpp b/test/Format/cursor.cpp index c7d576b..e41c0d5 100644 --- a/test/Format/cursor.cpp +++ b/test/Format/cursor.cpp @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp -// RUN: clang-format -style=LLVM %t2.cpp -cursor=6 > %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s -// CHECK: {{^\{ "Cursor": 4, }} +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=6 \ +// RUN: | FileCheck -strict-whitespace %s +// CHECK: {{^\{ "Cursor": 3, }} // CHECK: {{^int\ \i;$}} int i; diff --git a/test/Format/disable-format.cpp b/test/Format/disable-format.cpp index 59484b3..a1e8cd1 100644 --- a/test/Format/disable-format.cpp +++ b/test/Format/disable-format.cpp @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-format -style=none -i %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=none \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: int i; int i; diff --git a/test/Format/disable-include-sorting.cpp b/test/Format/disable-include-sorting.cpp new file mode 100644 index 0000000..875a0af --- /dev/null +++ b/test/Format/disable-include-sorting.cpp @@ -0,0 +1,10 @@ +// RUN: clang-format %s | FileCheck %s +// RUN: clang-format %s -sort-includes -style="{SortIncludes: false}" | FileCheck %s +// RUN: clang-format %s -sort-includes=false | FileCheck %s -check-prefix=NOT-SORTED + +#include <b> +#include <a> +// CHECK: <a> +// CHECK-NEXT: <b> +// NOT-SORTED: <b> +// NOT-SORTED-NEXT: <a> diff --git a/test/Format/incomplete.cpp b/test/Format/incomplete.cpp index bd2c74c..8a65fad 100644 --- a/test/Format/incomplete.cpp +++ b/test/Format/incomplete.cpp @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp -// RUN: clang-format -style=LLVM %t2.cpp -cursor=0 > %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=0 \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{"IncompleteFormat": true}} // CHECK: {{^int\ \i;$}} int i; diff --git a/test/Format/language-detection.cpp b/test/Format/language-detection.cpp index bec444d..2a53be7 100644 --- a/test/Format/language-detection.cpp +++ b/test/Format/language-detection.cpp @@ -1,7 +1,9 @@ -// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.js -// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp -// RUN: clang-format -style=llvm %t.js | FileCheck -strict-whitespace -check-prefix=CHECK1 %s -// RUN: clang-format -style=llvm %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK2 %s +// RUN: grep -Ev "// *[A-Z0-9_]+:" %s \ +// RUN: | clang-format -style=llvm -assume-filename=foo.js \ +// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK1 %s +// RUN: grep -Ev "// *[A-Z0-9_]+:" %s \ +// RUN: | clang-format -style=llvm -assume-filename=foo.cpp \ +// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK2 %s // CHECK1: {{^a >>>= b;$}} // CHECK2: {{^a >> >= b;$}} a >>>= b; diff --git a/test/Format/line-ranges.cpp b/test/Format/line-ranges.cpp index 370445a..e81e962 100644 --- a/test/Format/line-ranges.cpp +++ b/test/Format/line-ranges.cpp @@ -1,11 +1,11 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-format -style=LLVM -lines=1:1 -lines=5:5 -i %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style=LLVM -lines=1:1 -lines=5:5 \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{^int\ \*i;$}} int*i; -// CHECK: {{^\ \ int\ \ \*\ \ i;$}} - int * i; +// CHECK: {{^int\ \ \*\ \ i;$}} +int * i; -// CHECK: {{^\ \ int\ \*i;$}} - int * i; +// CHECK: {{^int\ \*i;$}} +int * i; diff --git a/test/Format/ranges.cpp b/test/Format/ranges.cpp index c7fdd4b..66b984e 100644 --- a/test/Format/ranges.cpp +++ b/test/Format/ranges.cpp @@ -1,11 +1,11 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-format -style=LLVM -offset=2 -length=0 -offset=28 -length=0 -i %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style=LLVM -offset=2 -length=0 -offset=28 -length=0 \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{^int\ \*i;$}} - int*i; +int*i; -// CHECK: {{^\ \ int\ \ \*\ \ i;$}} - int * i; +// CHECK: {{^int\ \ \*\ \ i;$}} +int * i; -// CHECK: {{^\ \ int\ \*i;$}} - int * i; +// CHECK: {{^int\ \*i;$}} +int * i; diff --git a/test/Format/style-on-command-line.cpp b/test/Format/style-on-command-line.cpp index 3f4f77a..08da60a 100644 --- a/test/Format/style-on-command-line.cpp +++ b/test/Format/style-on-command-line.cpp @@ -1,17 +1,16 @@ -// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp -// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK1 %s -// RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK2 %s -// RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s -// RUN: clang-format -style="{lsjd}" %t.cpp -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s +// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s +// RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s +// RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s +// RUN: clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format -// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK5 %s +// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s // RUN: printf "\n" > %T/.clang-format -// RUN: clang-format -style=file -fallback-style=webkit %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s +// RUN: clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s // RUN: rm %T/.clang-format // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format -// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK7 %s -// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK8 %s -// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK9 %s +// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s +// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s +// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s void f() { // CHECK1: {{^ int\* i;$}} // CHECK2: {{^ int \*i;$}} diff --git a/test/Format/xmloutput.cpp b/test/Format/xmloutput.cpp new file mode 100644 index 0000000..3d84a2f --- /dev/null +++ b/test/Format/xmloutput.cpp @@ -0,0 +1,12 @@ +// RUN: clang-format -output-replacements-xml -sort-includes %s \ +// RUN: | FileCheck -strict-whitespace %s + +// CHECK: <?xml +// CHECK-NEXT: {{<replacements.*incomplete_format='false'}} +// CHECK-NEXT: {{<replacement.*#include <a> #include <b><}} +// CHECK-NEXT: {{<replacement.*> <}} +// CHECK-NEXT: {{<replacement.*> <}} +#include <b> +#include <a> + +int a;int*b; |