Home | History | Annotate | Download | only in Format
      1 // RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp
      2 // 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
      4 // 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
      6 // RUN: [ ! -e %T/.clang-format ] || rm %T/.clang-format
      7 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
      8 // RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
      9 // RUN: printf "\n" > %T/.clang-format
     10 // RUN: clang-format -style=file -fallback-style=webkit %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
     11 // RUN: [ ! -e %T/.clang-format ] || rm %T/.clang-format
     12 // RUN: [ ! -e %T/_clang-format ] || rm %T/_clang-format
     13 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
     14 // RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
     15 // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
     16 // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
     17 void f() {
     18 // CHECK1: {{^        int\* i;$}}
     19 // CHECK2: {{^       int \*i;$}}
     20 // CHECK3: Unknown value for BasedOnStyle: invalid
     21 // CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
     22 // CHECK3: {{^  int \*i;$}}
     23 // CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
     24 // CHECK4: {{^  int \*i;$}}
     25 // CHECK5: {{^     int\* i;$}}
     26 // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
     27 // CHECK6: {{^Can't find usable .clang-format, using webkit style$}}
     28 // CHECK6: {{^    int\* i;$}}
     29 // CHECK7: {{^      int\* i;$}}
     30 // CHECK8: {{^  int\* i;$}}
     31 // CHECK9: {{^    int \*i;$}}
     32 int*i;
     33 int j;
     34 }
     35