Skip to content

Commit 1237346

Browse files
committed
[clang-tidy] add test with carets
1 parent 3f410e8 commit 1237346

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
// RUN: clang-tidy -checks=-*,readability-magic-numbers %s -- 2>&1 | FileCheck %s --check-prefix=CHECK-NORMAL
2-
// RUN: clang-tidy -checks=-*,readability-magic-numbers -quiet %s -- 2>&1 | FileCheck %s --check-prefix=CHECK-QUIET
1+
// This test ensures that the --quiet flag only suppresses the "X warnings generated"
2+
// message while keeping all diagnostic information including caret indicators (^).
33

4-
// Normal mode should show warning count
5-
// CHECK-NORMAL: 1 warning generated
6-
// CHECK-NORMAL: warning: 42 is a magic number
4+
// RUN: clang-tidy -checks=-*,readability-magic-numbers,clang-diagnostic-sign-compare %s -- \
5+
// RUN: -Wsign-compare 2>&1 | FileCheck %s --check-prefix=CHECK-NORMAL
6+
// RUN: clang-tidy -checks=-*,readability-magic-numbers,clang-diagnostic-sign-compare -quiet %s -- \
7+
// RUN: -Wsign-compare 2>&1 | FileCheck %s --check-prefix=CHECK-QUIET
8+
9+
// CHECK-NORMAL: 2 warnings generated
10+
// CHECK-NORMAL-DAG: warning: 42 is a magic number
11+
// CHECK-NORMAL-DAG: {{[ ]*\^}}
12+
// CHECK-NORMAL-DAG: warning: comparison of integers of different signs
13+
// CHECK-NORMAL-DAG: {{[ ]*~ \^ ~}}
714

8-
// Quiet mode should suppress warning count but show diagnostic
9-
// CHECK-QUIET: warning: 42 is a magic number
1015
// CHECK-QUIET-NOT: {{[0-9]+}} warning{{s?}} generated
16+
// CHECK-QUIET-DAG: warning: 42 is a magic number
17+
// CHECK-QUIET-DAG: {{[ ]*\^}}
18+
// CHECK-QUIET-DAG: warning: comparison of integers of different signs
19+
// CHECK-QUIET-DAG: {{[ ]*~ \^ ~}}
1120

1221
int main() {
13-
int x = 42; // This will trigger readability-magic-numbers
22+
const int CONST_VAL = 10;
23+
int x = 42; // trigger 'readability-magic-numbers' with caret: ^
24+
unsigned int y = CONST_VAL;
25+
return x < y; // trigger 'clang-diagnostic-sign-compare' with caret: ^
1426
}

0 commit comments

Comments
 (0)