Skip to content

Commit 00a1978

Browse files
committed
C++: Add a guard condition test with an example of a negated less-than relation.
1 parent 2076c1c commit 00a1978

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

cpp/ql/test/library-tests/controlflow/guards/Guards.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
| test.c:164:8:164:8 | s |
3333
| test.c:170:8:170:9 | ! ... |
3434
| test.c:170:9:170:9 | s |
35+
| test.c:176:8:176:15 | ! ... |
36+
| test.c:176:10:176:14 | ... < ... |
3537
| test.cpp:18:8:18:10 | call to get |
3638
| test.cpp:31:7:31:13 | ... == ... |
3739
| test.cpp:42:13:42:20 | call to getABool |

cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,15 @@
381381
| 170 | s != 0 when s is true |
382382
| 170 | s == 0 when ! ... is true |
383383
| 170 | s == 0 when s is false |
384+
| 176 | ! ... != 0 when ! ... is true |
385+
| 176 | ! ... != 0 when ... < ... is false |
386+
| 176 | ! ... != 1 when ! ... is false |
387+
| 176 | ! ... != 1 when ... < ... is true |
388+
| 176 | ! ... == 0 when ! ... is false |
389+
| 176 | ! ... == 0 when ... < ... is true |
390+
| 176 | ! ... == 1 when ! ... is true |
391+
| 176 | ! ... == 1 when ... < ... is false |
392+
| 176 | ... < ... != 0 when ! ... is false |
393+
| 176 | ... < ... != 0 when ... < ... is true |
394+
| 176 | ... < ... == 0 when ! ... is true |
395+
| 176 | ... < ... == 0 when ... < ... is false |

cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
| test.c:164:8:164:8 | s | true | 164 | 166 |
8686
| test.c:170:8:170:9 | ! ... | true | 170 | 172 |
8787
| test.c:170:9:170:9 | s | false | 170 | 172 |
88+
| test.c:176:8:176:15 | ! ... | true | 176 | 178 |
89+
| test.c:176:10:176:14 | ... < ... | false | 176 | 178 |
8890
| test.cpp:18:8:18:10 | call to get | true | 19 | 19 |
8991
| test.cpp:31:7:31:13 | ... == ... | false | 30 | 30 |
9092
| test.cpp:31:7:31:13 | ... == ... | false | 34 | 34 |

cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,12 @@ unary
461461
| test.c:170:9:170:9 | s | test.c:170:8:170:9 | ! ... | != | 0 | 170 | 172 |
462462
| test.c:170:9:170:9 | s | test.c:170:8:170:9 | ! ... | == | 1 | 170 | 172 |
463463
| test.c:170:9:170:9 | s | test.c:170:9:170:9 | s | == | 0 | 170 | 172 |
464+
| test.c:176:8:176:15 | ! ... | test.c:176:8:176:15 | ! ... | != | 0 | 176 | 178 |
465+
| test.c:176:8:176:15 | ! ... | test.c:176:8:176:15 | ! ... | == | 1 | 176 | 178 |
466+
| test.c:176:8:176:15 | ! ... | test.c:176:10:176:14 | ... < ... | == | 0 | 176 | 178 |
467+
| test.c:176:10:176:14 | ... < ... | test.c:176:8:176:15 | ! ... | != | 0 | 176 | 178 |
468+
| test.c:176:10:176:14 | ... < ... | test.c:176:8:176:15 | ! ... | == | 1 | 176 | 178 |
469+
| test.c:176:10:176:14 | ... < ... | test.c:176:10:176:14 | ... < ... | == | 0 | 176 | 178 |
464470
| test.cpp:18:8:18:10 | call to get | test.cpp:18:8:18:10 | call to get | != | 0 | 19 | 19 |
465471
| test.cpp:18:8:18:10 | call to get | test.cpp:18:8:18:10 | call to get | == | 1 | 19 | 19 |
466472
| test.cpp:31:7:31:13 | ... == ... | test.cpp:31:7:31:7 | x | != | -1 | 30 | 30 |

cpp/ql/test/library-tests/controlflow/guards/test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,11 @@ void test8(short s) {
169169
void test9(short s) {
170170
if(!s) {
171171

172+
}
173+
}
174+
175+
void test10(int a, int b) {
176+
if(!(a < b)) {
177+
172178
}
173179
}

0 commit comments

Comments
 (0)