blob: 3f4f77ad0c31ff48be720f2336b33bcb77241f8e [file] [log] [blame]
Alexander Kornienko22479f72013-09-02 14:25:56 +00001// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp
Alexander Kornienko006b5c82013-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
Daniel Jaspere1d91412013-12-03 06:48:41 +00004// 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
Daniel Dunbar14e88a12013-08-29 03:02:39 +00006// RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
Chandler Carruthbc36e6e02013-09-02 07:42:02 +00007// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
Alexander Kornienko9acf3db2013-09-02 13:44:16 +00008// RUN: printf "\n" > %T/.clang-format
Alexander Kornienkobc4ae442013-12-02 15:21:38 +00009// RUN: clang-format -style=file -fallback-style=webkit %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
Benjamin Kramerfea47d42015-06-09 12:41:02 +000010// RUN: rm %T/.clang-format
Hans Wennborg9f6581b2013-09-10 15:41:12 +000011// RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
12// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
Daniel Jasper553d4872014-06-17 12:40:34 +000013// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
14// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
Alexander Kornienko006b5c82013-05-19 00:53:30 +000015void f() {
16// CHECK1: {{^ int\* i;$}}
17// CHECK2: {{^ int \*i;$}}
18// CHECK3: Unknown value for BasedOnStyle: invalid
Rafael Espindola374597a2014-06-12 12:40:04 +000019// CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko006b5c82013-05-19 00:53:30 +000020// CHECK3: {{^ int \*i;$}}
Rafael Espindola374597a2014-06-12 12:40:04 +000021// CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko006b5c82013-05-19 00:53:30 +000022// CHECK4: {{^ int \*i;$}}
Chandler Carruthbc36e6e02013-09-02 07:42:02 +000023// CHECK5: {{^ int\* i;$}}
Rafael Espindola374597a2014-06-12 12:40:04 +000024// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
Alexander Kornienkobc4ae442013-12-02 15:21:38 +000025// CHECK6: {{^ int\* i;$}}
Hans Wennborg9f6581b2013-09-10 15:41:12 +000026// CHECK7: {{^ int\* i;$}}
Daniel Jasper553d4872014-06-17 12:40:34 +000027// CHECK8: {{^ int\* i;$}}
28// CHECK9: {{^ int \*i;$}}
Alexander Kornienko006b5c82013-05-19 00:53:30 +000029int*i;
30int j;
31}
Reid Klecknerf8439942015-06-09 17:47:59 +000032
33// On Windows, the 'rm' commands fail when the previous process is still alive.
34// This happens enough to make the test useless.
35// REQUIRES: shell