Commit f840421
committed
Improve the test assertion failure message when the wrong enum variant is used in
Previously, the match explanation when the wrong enum variant was used would just state that there was no such field:
```
Value of: actual
Expected: is AnEnum :: B which has field `0`, which is equal to 123
Actual: A(123),
which has no field `0`
```
This is confusing, since the actual value _does_ have such a field. It's just of the wrong enum variant.
This fixes the error message to indicate that the wrong variant was supplied:
```
Value of: actual
Expected: is AnEnum :: B which has field `0`, which is equal to 123
Actual: A(123),
which has the wrong enum variant `A`
```
To output the supplied enum variant, it is necessary to construct the debug output and strip it of any fields it may have. This is inefficient, but unfortunately there is no obvious way to directly debug-output just the enum variant with no fields.matches_pattern!.1 parent 30cfca0 commit f840421
File tree
3 files changed
+90
-25
lines changed- googletest
- src/matchers
- tests
3 files changed
+90
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
125 | 167 | | |
126 | 168 | | |
127 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
191 | 214 | | |
192 | 215 | | |
193 | 216 | | |
| |||
972 | 995 | | |
973 | 996 | | |
974 | 997 | | |
975 | | - | |
976 | | - | |
| 998 | + | |
| 999 | + | |
977 | 1000 | | |
978 | 1001 | | |
979 | 1002 | | |
| |||
1043 | 1066 | | |
1044 | 1067 | | |
1045 | 1068 | | |
1046 | | - | |
1047 | | - | |
| 1069 | + | |
| 1070 | + | |
1048 | 1071 | | |
1049 | 1072 | | |
1050 | 1073 | | |
| |||
1270 | 1293 | | |
1271 | 1294 | | |
1272 | 1295 | | |
1273 | | - | |
1274 | | - | |
| 1296 | + | |
| 1297 | + | |
1275 | 1298 | | |
1276 | 1299 | | |
1277 | 1300 | | |
| |||
1320 | 1343 | | |
1321 | 1344 | | |
1322 | 1345 | | |
1323 | | - | |
1324 | | - | |
| 1346 | + | |
| 1347 | + | |
1325 | 1348 | | |
1326 | 1349 | | |
1327 | 1350 | | |
| |||
1376 | 1399 | | |
1377 | 1400 | | |
1378 | 1401 | | |
1379 | | - | |
1380 | | - | |
| 1402 | + | |
| 1403 | + | |
1381 | 1404 | | |
1382 | 1405 | | |
1383 | 1406 | | |
| |||
1404 | 1427 | | |
1405 | 1428 | | |
1406 | 1429 | | |
1407 | | - | |
1408 | | - | |
| 1430 | + | |
| 1431 | + | |
1409 | 1432 | | |
1410 | 1433 | | |
1411 | 1434 | | |
| |||
1463 | 1486 | | |
1464 | 1487 | | |
1465 | 1488 | | |
1466 | | - | |
1467 | | - | |
| 1489 | + | |
| 1490 | + | |
1468 | 1491 | | |
1469 | 1492 | | |
1470 | 1493 | | |
| |||
1491 | 1514 | | |
1492 | 1515 | | |
1493 | 1516 | | |
1494 | | - | |
1495 | | - | |
| 1517 | + | |
| 1518 | + | |
1496 | 1519 | | |
1497 | 1520 | | |
1498 | 1521 | | |
| |||
1519 | 1542 | | |
1520 | 1543 | | |
1521 | 1544 | | |
1522 | | - | |
1523 | | - | |
| 1545 | + | |
| 1546 | + | |
1524 | 1547 | | |
1525 | 1548 | | |
1526 | 1549 | | |
| |||
1551 | 1574 | | |
1552 | 1575 | | |
1553 | 1576 | | |
1554 | | - | |
1555 | | - | |
| 1577 | + | |
| 1578 | + | |
1556 | 1579 | | |
1557 | 1580 | | |
1558 | 1581 | | |
| |||
0 commit comments