blob: 08da60a988d163062542882982a81aba183010dc [file] [log] [blame]
Pirama Arumuga Nainar87d948e2016-03-03 15:49:35 -08001// 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 Dunbara4516a52013-08-29 03:02:39 +00005// RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
Pirama Arumuga Nainar87d948e2016-03-03 15:49:35 -08006// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
Alexander Kornienko3361f102013-09-02 13:44:16 +00007// RUN: printf "\n" > %T/.clang-format
Pirama Arumuga Nainar87d948e2016-03-03 15:49:35 -08008// 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 Nainarb6d69932015-07-01 12:25:36 -07009// RUN: rm %T/.clang-format
Hans Wennborg9a7a50e2013-09-10 15:41:12 +000010// RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
Pirama Arumuga Nainar87d948e2016-03-03 15:49:35 -080011// 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 Kornienko885f87b2013-05-19 00:53:30 +000014void f() {
15// CHECK1: {{^ int\* i;$}}
16// CHECK2: {{^ int \*i;$}}
17// CHECK3: Unknown value for BasedOnStyle: invalid
Stephen Hinesc568f1e2014-07-21 00:47:37 -070018// CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko885f87b2013-05-19 00:53:30 +000019// CHECK3: {{^ int \*i;$}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070020// CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko885f87b2013-05-19 00:53:30 +000021// CHECK4: {{^ int \*i;$}}
Chandler Carruth439fc852013-09-02 07:42:02 +000022// CHECK5: {{^ int\* i;$}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070023// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
Stephen Hines651f13c2014-04-23 16:59:28 -070024// CHECK6: {{^ int\* i;$}}
Hans Wennborg9a7a50e2013-09-10 15:41:12 +000025// CHECK7: {{^ int\* i;$}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070026// CHECK8: {{^ int\* i;$}}
27// CHECK9: {{^ int \*i;$}}
Alexander Kornienko885f87b2013-05-19 00:53:30 +000028int*i;
29int j;
30}
Pirama Arumuga Nainarb6d69932015-07-01 12:25:36 -070031
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