2015-10-20 00:21:29 +08:00
|
|
|
// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
|
|
|
|
// RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
|
2017-01-17 08:12:27 +08:00
|
|
|
// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s
|
|
|
|
// RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s
|
2017-08-16 03:47:06 +08:00
|
|
|
// RUN: mkdir -p %t
|
|
|
|
// RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %t/.clang-format
|
|
|
|
// RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
|
|
|
|
// RUN: printf "\n" > %t/.clang-format
|
|
|
|
// RUN: not clang-format -style=file -fallback-style=webkit -assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
|
|
|
|
// RUN: rm %t/.clang-format
|
|
|
|
// RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %t/_clang-format
|
|
|
|
// RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
|
2015-10-20 00:21:29 +08:00
|
|
|
// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
|
|
|
|
// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
|
2017-01-20 09:22:42 +08:00
|
|
|
|
|
|
|
// Fallback style tests
|
|
|
|
// Test config file with no based style, and fallback style "none", formatting is applied
|
2017-08-16 03:47:06 +08:00
|
|
|
// RUN: printf "IndentWidth: 6\n" > %t/_clang-format
|
|
|
|
// RUN: clang-format -style=file -fallback-style=none -assume-filename=%t/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s
|
2017-01-20 09:22:42 +08:00
|
|
|
// Test yaml with no based style, and fallback style "none", LLVM formatting applied
|
2017-01-23 21:20:23 +08:00
|
|
|
// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | FileCheck -strict-whitespace -check-prefix=CHECK11 %s
|
2017-01-20 09:22:42 +08:00
|
|
|
|
2013-05-19 08:53:30 +08:00
|
|
|
void f() {
|
|
|
|
// CHECK1: {{^ int\* i;$}}
|
|
|
|
// CHECK2: {{^ int \*i;$}}
|
|
|
|
// CHECK3: Unknown value for BasedOnStyle: invalid
|
2017-01-17 08:12:27 +08:00
|
|
|
// CHECK3: Error parsing -style: {{I|i}}nvalid argument
|
|
|
|
// CHECK4: Error parsing -style: {{I|i}}nvalid argument
|
2013-09-02 15:42:02 +08:00
|
|
|
// CHECK5: {{^ int\* i;$}}
|
2014-06-12 20:40:04 +08:00
|
|
|
// CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
|
2013-09-10 23:41:12 +08:00
|
|
|
// CHECK7: {{^ int\* i;$}}
|
2014-06-17 20:40:34 +08:00
|
|
|
// CHECK8: {{^ int\* i;$}}
|
|
|
|
// CHECK9: {{^ int \*i;$}}
|
2017-01-23 21:20:23 +08:00
|
|
|
// CHECK10: {{^ int \*i;$}}
|
|
|
|
// CHECK11: {{^ int \*i;$}}
|
2013-05-19 08:53:30 +08:00
|
|
|
int*i;
|
|
|
|
int j;
|
|
|
|
}
|
2015-06-10 01:47:59 +08:00
|
|
|
|
|
|
|
// On Windows, the 'rm' commands fail when the previous process is still alive.
|
|
|
|
// This happens enough to make the test useless.
|
2019-09-10 16:48:33 +08:00
|
|
|
// REQUIRES: shell
|