blob: 08da60a988d163062542882982a81aba183010dc [file] [log] [blame]
Nico Weber3cb667e2015-10-19 16:21:29 +00001// 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 Dunbar14e88a12013-08-29 03:02:39 +00005// RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
Nico Weber3cb667e2015-10-19 16:21:29 +00006// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
Alexander Kornienko9acf3db2013-09-02 13:44:16 +00007// RUN: printf "\n" > %T/.clang-format
Nico Weber3cb667e2015-10-19 16:21:29 +00008// RUN: clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
Benjamin Kramerfea47d42015-06-09 12:41:02 +00009// RUN: rm %T/.clang-format
Hans Wennborg9f6581b2013-09-10 15:41:12 +000010// RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
Nico Weber3cb667e2015-10-19 16:21:29 +000011// 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 Kornienko006b5c82013-05-19 00:53:30 +000014void f() {
15// CHECK1: {{^ int\* i;$}}
16// CHECK2: {{^ int \*i;$}}
17// CHECK3: Unknown value for BasedOnStyle: invalid
Rafael Espindola374597a2014-06-12 12:40:04 +000018// CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko006b5c82013-05-19 00:53:30 +000019// CHECK3: {{^ int \*i;$}}
Rafael Espindola374597a2014-06-12 12:40:04 +000020// CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
Alexander Kornienko006b5c82013-05-19 00:53:30 +000021// CHECK4: {{^ int \*i;$}}
Chandler Carruthbc36e6e02013-09-02 07:42:02 +000022// CHECK5: {{^ int\* i;$}}
Rafael Espindola374597a2014-06-12 12:40:04 +000023// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
Alexander Kornienkobc4ae442013-12-02 15:21:38 +000024// CHECK6: {{^ int\* i;$}}
Hans Wennborg9f6581b2013-09-10 15:41:12 +000025// CHECK7: {{^ int\* i;$}}
Daniel Jasper553d4872014-06-17 12:40:34 +000026// CHECK8: {{^ int\* i;$}}
27// CHECK9: {{^ int \*i;$}}
Alexander Kornienko006b5c82013-05-19 00:53:30 +000028int*i;
29int j;
30}
Reid Klecknerf8439942015-06-09 17:47:59 +000031
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