Skip to content

Commit d783d8e

Browse files
authored
Add test coverage for literal exclusion cases
1 parent 742ef16 commit d783d8e

2 files changed

Lines changed: 33 additions & 18 deletions

File tree

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
| test.cpp:111:3:111:12 | 2147483648 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
2-
| test.cpp:116:3:116:20 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
3-
| test.cpp:139:3:139:21 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
4-
| test.cpp:162:3:162:21 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
5-
| test.cpp:185:3:185:22 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
6-
| test.cpp:208:3:208:22 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
7-
| test.cpp:227:3:227:14 | 2147483648 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
8-
| test.cpp:232:3:232:25 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
9-
| test.cpp:249:3:249:26 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
10-
| test.cpp:266:3:266:26 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
11-
| test.cpp:283:3:283:27 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
12-
| test.cpp:300:3:300:27 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
13-
| test.cpp:315:3:315:36 | 2147483648 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
14-
| test.cpp:322:3:322:68 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
15-
| test.cpp:365:3:365:69 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
16-
| test.cpp:412:3:412:69 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
17-
| test.cpp:457:3:457:70 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
18-
| test.cpp:502:3:502:70 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
1+
| test.cpp:126:3:126:12 | 2147483648 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
2+
| test.cpp:131:3:131:20 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
3+
| test.cpp:154:3:154:21 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
4+
| test.cpp:177:3:177:21 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
5+
| test.cpp:200:3:200:22 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
6+
| test.cpp:223:3:223:22 | 9223372036854775808 | Hex literal is an unsigned integer but does not include a 'U' suffix. |
7+
| test.cpp:242:3:242:14 | 2147483648 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
8+
| test.cpp:247:3:247:25 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
9+
| test.cpp:264:3:264:26 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
10+
| test.cpp:281:3:281:26 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
11+
| test.cpp:298:3:298:27 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
12+
| test.cpp:315:3:315:27 | 9223372036854775808 | Octal literal is an unsigned integer but does not include a 'U' suffix. |
13+
| test.cpp:330:3:330:36 | 2147483648 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
14+
| test.cpp:337:3:337:68 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
15+
| test.cpp:380:3:380:69 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
16+
| test.cpp:427:3:427:69 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
17+
| test.cpp:472:3:472:70 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |
18+
| test.cpp:517:3:517:70 | 9223372036854775808 | Binary literal is an unsigned integer but does not include a 'U' suffix. |

cpp/common/test/rules/unsignedintegerliteralsnotappropriatelysuffixed/test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ void test_decimal_constants() {
105105
// than max long long int
106106
}
107107

108+
constexpr unsigned long long operator""_km(unsigned long long value) {
109+
return value;
110+
}
111+
112+
void test_user_defined_literal_exclusion() {
113+
0x80000000_km; // COMPLIANT - user-defined literal argument should be excluded
114+
}
115+
116+
template <typename T>
117+
unsigned long long instantiated_literal_exclusion() {
118+
return 0x80000000; // COMPLIANT - template instantiation should be excluded
119+
}
120+
121+
void instantiate_literal_exclusion() { (void)instantiated_literal_exclusion<int>(); }
122+
108123
void test_hexadecimal_constants() {
109124
0x0; // COMPLIANT - uses signed int
110125
0x7FFFFFFF; // COMPLIANT - max value held by signed int

0 commit comments

Comments
 (0)