Skip to content

Commit b7d2e0c

Browse files
committed
C++: Make all the tests meaningful.
1 parent 6e18be4 commit b7d2e0c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/inconsistentLoopDirection/inconsistentLoopDirection.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ void IntendedOverflow()
190190
for (i = 63; i < 255; i--) {} // GOOD
191191

192192
for (i = m - 1; i < m; i--) {} // GOOD
193-
for (i = m - 1; i < m; i--) {} // DUBIOUS
194-
for (i = m - 1; i < m; i--) {} // GOOD
193+
for (i = m - 2; i < m; i--) {} // DUBIOUS
194+
for (i = m; i < m + 1; i--) {} // GOOD
195195

196196
for (s = 63; s < 64; s--) {} // BAD (signed numbers don't wrap at 0 / at all)
197+
for (s = m + 1; s < m; s--) {} // BAD (never runs)
197198
}

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/inconsistentLoopDirection/inconsistentLoopDirection.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
| inconsistentLoopDirection.cpp:175:5:175:36 | for(...;...;...) ... | Ill-defined for-loop: a loop using variable "i" counts downward from a value (0), but the terminal condition is higher (10). |
2222
| inconsistentLoopDirection.cpp:179:5:179:38 | for(...;...;...) ... | Ill-defined for-loop: a loop using variable "i" counts upward from a value (100), but the terminal condition is lower (0). |
2323
| inconsistentLoopDirection.cpp:196:5:196:32 | for(...;...;...) ... | Ill-defined for-loop: a loop using variable "s" counts downward from a value (63), but the terminal condition is higher (64). |
24+
| inconsistentLoopDirection.cpp:197:5:197:34 | for(...;...;...) ... | Ill-defined for-loop: a loop using variable "s" counts downward from a value (... + ...), but the terminal condition is always false. |

0 commit comments

Comments
 (0)