Pirama Arumuga Nainar | 87d948e | 2016-03-03 15:49:35 -0800 | [diff] [blame] | 1 | // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s |
| 2 | // RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s |
| 3 | // RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s |
| 4 | // RUN: clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s |
Daniel Dunbar | a4516a5 | 2013-08-29 03:02:39 +0000 | [diff] [blame] | 5 | // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format |
Pirama Arumuga Nainar | 87d948e | 2016-03-03 15:49:35 -0800 | [diff] [blame] | 6 | // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s |
Alexander Kornienko | 3361f10 | 2013-09-02 13:44:16 +0000 | [diff] [blame] | 7 | // RUN: printf "\n" > %T/.clang-format |
Pirama Arumuga Nainar | 87d948e | 2016-03-03 15:49:35 -0800 | [diff] [blame] | 8 | // RUN: clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s |
Pirama Arumuga Nainar | b6d6993 | 2015-07-01 12:25:36 -0700 | [diff] [blame] | 9 | // RUN: rm %T/.clang-format |
Hans Wennborg | 9a7a50e | 2013-09-10 15:41:12 +0000 | [diff] [blame] | 10 | // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format |
Pirama Arumuga Nainar | 87d948e | 2016-03-03 15:49:35 -0800 | [diff] [blame] | 11 | // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s |
| 12 | // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s |
| 13 | // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 14 | void f() { |
| 15 | // CHECK1: {{^ int\* i;$}} |
| 16 | // CHECK2: {{^ int \*i;$}} |
| 17 | // CHECK3: Unknown value for BasedOnStyle: invalid |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 18 | // CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 19 | // CHECK3: {{^ int \*i;$}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 20 | // CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 21 | // CHECK4: {{^ int \*i;$}} |
Chandler Carruth | 439fc85 | 2013-09-02 07:42:02 +0000 | [diff] [blame] | 22 | // CHECK5: {{^ int\* i;$}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 23 | // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}} |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 24 | // CHECK6: {{^ int\* i;$}} |
Hans Wennborg | 9a7a50e | 2013-09-10 15:41:12 +0000 | [diff] [blame] | 25 | // CHECK7: {{^ int\* i;$}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 26 | // CHECK8: {{^ int\* i;$}} |
| 27 | // CHECK9: {{^ int \*i;$}} |
Alexander Kornienko | 885f87b | 2013-05-19 00:53:30 +0000 | [diff] [blame] | 28 | int*i; |
| 29 | int j; |
| 30 | } |
Pirama Arumuga Nainar | b6d6993 | 2015-07-01 12:25:36 -0700 | [diff] [blame] | 31 | |
| 32 | // On Windows, the 'rm' commands fail when the previous process is still alive. |
| 33 | // This happens enough to make the test useless. |
| 34 | // REQUIRES: shell |