llvm-capstone/clang/test/Format/line-ranges.cpp
owenca 615f838f73 [clang-format] Fix an assertion failure on -lines=0:n
Also fixed the error message for start line > end line and added test cases.

Fixes #56438.

Differential Revision: https://reviews.llvm.org/D129348
2022-07-08 23:41:16 -07:00

20 lines
596 B
C++

// RUN: grep -Ev "// *[A-Z-]+:" %s \
// RUN: | clang-format -style=LLVM -lines=1:1 -lines=5:5 \
// RUN: | FileCheck -strict-whitespace %s
// CHECK: {{^int\ \*i;$}}
int*i;
// CHECK: {{^int\ \ \*\ \ i;$}}
int * i;
// CHECK: {{^int\ \*i;$}}
int * i;
// RUN: not clang-format -lines=0:1 < %s 2>&1 \
// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK0 %s
// CHECK0: error: start line should be at least 1
// RUN: not clang-format -lines=2:1 < %s 2>&1 \
// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
// CHECK1: error: start line should not exceed end line