• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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
5 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
6 // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
7 // RUN: printf "\n" > %T/.clang-format
8 // RUN: clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
9 // RUN: rm %T/.clang-format
10 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
11 // 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
f()14 void f() {
15 // CHECK1: {{^        int\* i;$}}
16 // CHECK2: {{^       int \*i;$}}
17 // CHECK3: Unknown value for BasedOnStyle: invalid
18 // CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
19 // CHECK3: {{^  int \*i;$}}
20 // CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
21 // CHECK4: {{^  int \*i;$}}
22 // CHECK5: {{^     int\* i;$}}
23 // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
24 // CHECK6: {{^    int\* i;$}}
25 // CHECK7: {{^      int\* i;$}}
26 // CHECK8: {{^  int\* i;$}}
27 // CHECK9: {{^    int \*i;$}}
28 int*i;
29 int j;
30 }
31 
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
35