Alexander Kornienko | 4ca401b | 2013-09-02 14:25:56 +0000 | [diff] [blame] | 1 | // RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 2 | // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK1 %s |
| 3 | // RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK2 %s |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 4 | // RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s |
| 5 | // RUN: clang-format -style="{lsjd}" %t.cpp -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 6 | // RUN: [ ! -e %T/.clang-format ] || rm %T/.clang-format |
Daniel Dunbar | a4516a5 | 2013-08-29 03:02:39 +0000 | [diff] [blame] | 7 | // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format |
Chandler Carruth | 439fc85 | 2013-09-02 07:42:02 +0000 | [diff] [blame] | 8 | // RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK5 %s |
Alexander Kornienko | 3361f10 | 2013-09-02 13:44:16 +0000 | [diff] [blame] | 9 | // RUN: printf "\n" > %T/.clang-format |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 10 | // RUN: clang-format -style=file -fallback-style=webkit %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s |
Hans Wennborg | 9a7a50e | 2013-09-10 15:41:12 +0000 | [diff] [blame] | 11 | // RUN: [ ! -e %T/.clang-format ] || rm %T/.clang-format |
| 12 | // RUN: [ ! -e %T/_clang-format ] || rm %T/_clang-format |
| 13 | // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format |
| 14 | // RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK7 %s |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 15 | // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK8 %s |
| 16 | // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK9 %s |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 17 | void f() { |
| 18 | // CHECK1: {{^ int\* i;$}} |
| 19 | // CHECK2: {{^ int \*i;$}} |
| 20 | // CHECK3: Unknown value for BasedOnStyle: invalid |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 21 | // CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 22 | // CHECK3: {{^ int \*i;$}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 23 | // CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 24 | // CHECK4: {{^ int \*i;$}} |
Chandler Carruth | 439fc85 | 2013-09-02 07:42:02 +0000 | [diff] [blame] | 25 | // CHECK5: {{^ int\* i;$}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 26 | // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}} |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 27 | // CHECK6: {{^Can't find usable .clang-format, using webkit style$}} |
| 28 | // CHECK6: {{^ int\* i;$}} |
Hans Wennborg | 9a7a50e | 2013-09-10 15:41:12 +0000 | [diff] [blame] | 29 | // CHECK7: {{^ int\* i;$}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 30 | // CHECK8: {{^ int\* i;$}} |
| 31 | // CHECK9: {{^ int \*i;$}} |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 32 | int*i; |
| 33 | int j; |
| 34 | } |