blob: 0d2d69206dc153e17bbb454f2ec95c666d6a9edd [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
Antonio Maiorano3adfb6a2017-01-17 00:12:27 +00003// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s
4// RUN: not 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
Antonio Maiorano3adfb6a2017-01-17 00:12:27 +00008// RUN: not 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
Antonio Maiorano3adfb6a2017-01-17 00:12:27 +000018// CHECK3: Error parsing -style: {{I|i}}nvalid argument
19// CHECK4: Error parsing -style: {{I|i}}nvalid argument
Chandler Carruthbc36e6e02013-09-02 07:42:02 +000020// CHECK5: {{^ int\* i;$}}
Rafael Espindola374597a2014-06-12 12:40:04 +000021// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
Hans Wennborg9f6581b2013-09-10 15:41:12 +000022// CHECK7: {{^ int\* i;$}}
Daniel Jasper553d4872014-06-17 12:40:34 +000023// CHECK8: {{^ int\* i;$}}
24// CHECK9: {{^ int \*i;$}}
Alexander Kornienko006b5c82013-05-19 00:53:30 +000025int*i;
26int j;
27}
Reid Klecknerf8439942015-06-09 17:47:59 +000028
29// On Windows, the 'rm' commands fail when the previous process is still alive.
30// This happens enough to make the test useless.
31// REQUIRES: shell