blob: 007022e74461ca0b040c4fc9b831609c917453f9 [file] [log] [blame]
Alexander Kornienko4ca401b2013-09-02 14:25:56 +00001// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp
Alexander Kornienko885f87b2013-05-19 00:53:30 +00002// 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 Hines651f13c2014-04-23 16:59:28 -07004// 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 Kornienko885f87b2013-05-19 00:53:30 +00006// RUN: [ ! -e %T/.clang-format ] || rm %T/.clang-format
Daniel Dunbara4516a52013-08-29 03:02:39 +00007// RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
Chandler Carruth439fc852013-09-02 07:42:02 +00008// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
Alexander Kornienko3361f102013-09-02 13:44:16 +00009// RUN: printf "\n" > %T/.clang-format
Stephen Hines651f13c2014-04-23 16:59:28 -070010// RUN: clang-format -style=file -fallback-style=webkit %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
Hans Wennborg9a7a50e2013-09-10 15:41:12 +000011// 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 Hinesc568f1e2014-07-21 00:47:37 -070015// 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 Kornienko885f87b2013-05-19 00:53:30 +000017void f() {
18// CHECK1: {{^ int\* i;$}}
19// CHECK2: {{^ int \*i;$}}
20// CHECK3: Unknown value for BasedOnStyle: invalid
Stephen Hinesc568f1e2014-07-21 00:47:37 -070021// CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko885f87b2013-05-19 00:53:30 +000022// CHECK3: {{^ int \*i;$}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070023// CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko885f87b2013-05-19 00:53:30 +000024// CHECK4: {{^ int \*i;$}}
Chandler Carruth439fc852013-09-02 07:42:02 +000025// CHECK5: {{^ int\* i;$}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070026// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
Stephen Hines651f13c2014-04-23 16:59:28 -070027// CHECK6: {{^Can't find usable .clang-format, using webkit style$}}
28// CHECK6: {{^ int\* i;$}}
Hans Wennborg9a7a50e2013-09-10 15:41:12 +000029// CHECK7: {{^ int\* i;$}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070030// CHECK8: {{^ int\* i;$}}
31// CHECK9: {{^ int \*i;$}}
Alexander Kornienko885f87b2013-05-19 00:53:30 +000032int*i;
33int j;
34}