xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/modernize/unary-static-assert.cpp (revision 95f50964fbf59dc6394898c0719ce8772cc24d25)
1 // RUN: %check_clang_tidy -std=c++17-or-later %s modernize-unary-static-assert %t
2 
3 #define FOO static_assert(sizeof(a) <= 15, "");
4 #define MSG ""
5 
f_textless(int a)6 void f_textless(int a) {
7   static_assert(sizeof(a) <= 10, "");
8   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use unary 'static_assert' when the string literal is an empty string [modernize-unary-static-assert]
9   // CHECK-FIXES: {{^}}  static_assert(sizeof(a) <= 10 );{{$}}
10   FOO
11   // CHECK-FIXES: {{^}}  FOO{{$}}
12   static_assert(sizeof(a) <= 17, MSG);
13   // CHECK-FIXES: {{^}}  static_assert(sizeof(a) <= 17, MSG);{{$}}
14 }
15 
f_with_tex(int a)16 void f_with_tex(int a) {
17   static_assert(sizeof(a) <= 10, "Size of variable a is out of range!");
18 }
19 
f_unary(int a)20 void f_unary(int a) { static_assert(sizeof(a) <= 10); }
21 
f_incorrect_assert()22 void f_incorrect_assert() { static_assert(""); }
23