Skip to content

Commit 96b644e

Browse files
committed
Rule 7.0.2: Add extra cast test cases
1 parent 8d0bb29 commit 96b644e

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

cpp/misra/test/rules/RULE-7-0-2/NoImplicitBoolConversion.expected

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
| test.cpp:127:13:127:16 | (bool)... | Conversion from 'int32_t *' to 'bool'. |
1212
| test.cpp:135:13:135:32 | static_cast<bool>... | Conversion from 'int' to 'bool'. |
1313
| test.cpp:136:13:136:14 | (bool)... | Conversion from 'uint8_t' to 'bool'. |
14-
| test.cpp:148:13:148:13 | call to operator bool | Conversion operator call from 'TestClassImplicit' to 'bool'. |
15-
| test.cpp:161:13:161:14 | (bool)... | Conversion from 'Color' to 'bool'. |
16-
| test.cpp:162:7:162:8 | (bool)... | Conversion from 'Color' to 'bool'. |
17-
| test.cpp:179:13:179:14 | (bool)... | Conversion from 'float' to 'bool'. |
18-
| test.cpp:180:13:180:14 | (bool)... | Conversion from 'double' to 'bool'. |
19-
| test.cpp:181:13:181:14 | (bool)... | Conversion from 'long double' to 'bool'. |
20-
| test.cpp:182:7:182:8 | (bool)... | Conversion from 'float' to 'bool'. |
21-
| test.cpp:184:7:184:8 | (bool)... | Conversion from 'double' to 'bool'. |
22-
| test.cpp:186:7:186:8 | (bool)... | Conversion from 'long double' to 'bool'. |
23-
| test.cpp:199:13:199:14 | (bool)... | Conversion from 'int32_t *' to 'bool'. |
24-
| test.cpp:211:13:211:14 | (bool)... | Conversion from '..:: *' to 'bool'. |
25-
| test.cpp:212:13:212:14 | (bool)... | Conversion from '..:: *' to 'bool'. |
14+
| test.cpp:139:13:139:19 | (bool)... | Conversion from 'int' to 'bool'. |
15+
| test.cpp:140:13:140:19 | (bool)... | Conversion from 'int' to 'bool'. |
16+
| test.cpp:150:13:150:13 | call to operator bool | Conversion operator call from 'TestClassImplicit' to 'bool'. |
17+
| test.cpp:163:13:163:14 | (bool)... | Conversion from 'Color' to 'bool'. |
18+
| test.cpp:164:7:164:8 | (bool)... | Conversion from 'Color' to 'bool'. |
19+
| test.cpp:181:13:181:14 | (bool)... | Conversion from 'float' to 'bool'. |
20+
| test.cpp:182:13:182:14 | (bool)... | Conversion from 'double' to 'bool'. |
21+
| test.cpp:183:13:183:14 | (bool)... | Conversion from 'long double' to 'bool'. |
22+
| test.cpp:184:7:184:8 | (bool)... | Conversion from 'float' to 'bool'. |
23+
| test.cpp:186:7:186:8 | (bool)... | Conversion from 'double' to 'bool'. |
24+
| test.cpp:188:7:188:8 | (bool)... | Conversion from 'long double' to 'bool'. |
25+
| test.cpp:201:13:201:14 | (bool)... | Conversion from 'int32_t *' to 'bool'. |
26+
| test.cpp:213:13:213:14 | (bool)... | Conversion from '..:: *' to 'bool'. |
27+
| test.cpp:214:13:214:14 | (bool)... | Conversion from '..:: *' to 'bool'. |

cpp/misra/test/rules/RULE-7-0-2/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ void test_assignment_to_bool() {
136136
bool l2 = g1; // NON_COMPLIANT
137137
bool l3 = (g1 < g2); // COMPLIANT
138138
bool l4 = g7; // COMPLIANT
139+
bool l5 = bool(4); // NON_COMPLIANT
140+
bool l6 = (bool)4; // NON_COMPLIANT
139141
}
140142

141143
void test_classes_with_bool_operators() {

0 commit comments

Comments
 (0)