Skip to content

Commit eadccf2

Browse files
committed
C++: Add test cases with missing inferred equalities.
1 parent d8ec6dd commit eadccf2

File tree

5 files changed

+158
-0
lines changed

5 files changed

+158
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,11 @@
6969
| test.cpp:168:8:168:8 | b |
7070
| test.cpp:176:7:176:8 | ! ... |
7171
| test.cpp:176:8:176:8 | c |
72+
| test.cpp:182:6:182:16 | ! ... |
73+
| test.cpp:182:8:182:9 | b1 |
74+
| test.cpp:182:8:182:15 | ... && ... |
75+
| test.cpp:182:14:182:15 | b2 |
76+
| test.cpp:193:6:193:16 | ! ... |
77+
| test.cpp:193:8:193:9 | b1 |
78+
| test.cpp:193:8:193:15 | ... \|\| ... |
79+
| test.cpp:193:14:193:15 | b2 |

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,12 @@
545545
| 182 | ! ... == 1 when ... && ... is false |
546546
| 182 | ... && ... != 0 when ! ... is false |
547547
| 182 | ... && ... != 0 when ... && ... is true |
548+
| 182 | ... && ... != 1 when ! ... is true |
549+
| 182 | ... && ... != 1 when ... && ... is false |
548550
| 182 | ... && ... == 0 when ! ... is true |
549551
| 182 | ... && ... == 0 when ... && ... is false |
552+
| 182 | ... && ... == 1 when ! ... is false |
553+
| 182 | ... && ... == 1 when ... && ... is true |
550554
| 182 | ... < ... != 0 when ... && ... is true |
551555
| 182 | ... < ... != 0 when ... < ... is true |
552556
| 182 | ... < ... != 1 when ... < ... is false |
@@ -559,6 +563,18 @@
559563
| 182 | ... >= ... == 0 when ... >= ... is false |
560564
| 182 | ... >= ... == 1 when ... && ... is true |
561565
| 182 | ... >= ... == 1 when ... >= ... is true |
566+
| 182 | b1 != 0 when ... && ... is true |
567+
| 182 | b1 != 0 when b1 is true |
568+
| 182 | b1 != 1 when b1 is false |
569+
| 182 | b1 == 0 when b1 is false |
570+
| 182 | b1 == 1 when ... && ... is true |
571+
| 182 | b1 == 1 when b1 is true |
572+
| 182 | b2 != 0 when ... && ... is true |
573+
| 182 | b2 != 0 when b2 is true |
574+
| 182 | b2 != 1 when b2 is false |
575+
| 182 | b2 == 0 when b2 is false |
576+
| 182 | b2 == 1 when ... && ... is true |
577+
| 182 | b2 == 1 when b2 is true |
562578
| 182 | foo < 1.0+0 when ... && ... is true |
563579
| 182 | foo < 1.0+0 when ... < ... is true |
564580
| 182 | foo < 9.999999999999999547e-07+0 when ... >= ... is false |
@@ -577,6 +593,34 @@
577593
| 190 | c != 0 when c is true |
578594
| 190 | c == 0 when ! ... is true |
579595
| 190 | c == 0 when c is false |
596+
| 193 | ! ... != 0 when ! ... is true |
597+
| 193 | ! ... != 0 when ... \|\| ... is false |
598+
| 193 | ! ... != 1 when ! ... is false |
599+
| 193 | ! ... != 1 when ... \|\| ... is true |
600+
| 193 | ! ... == 0 when ! ... is false |
601+
| 193 | ! ... == 0 when ... \|\| ... is true |
602+
| 193 | ! ... == 1 when ! ... is true |
603+
| 193 | ! ... == 1 when ... \|\| ... is false |
604+
| 193 | ... \|\| ... != 0 when ! ... is false |
605+
| 193 | ... \|\| ... != 0 when ... \|\| ... is true |
606+
| 193 | ... \|\| ... != 1 when ! ... is true |
607+
| 193 | ... \|\| ... != 1 when ... \|\| ... is false |
608+
| 193 | ... \|\| ... == 0 when ! ... is true |
609+
| 193 | ... \|\| ... == 0 when ... \|\| ... is false |
610+
| 193 | ... \|\| ... == 1 when ! ... is false |
611+
| 193 | ... \|\| ... == 1 when ... \|\| ... is true |
612+
| 193 | b1 != 0 when b1 is true |
613+
| 193 | b1 != 1 when ... \|\| ... is false |
614+
| 193 | b1 != 1 when b1 is false |
615+
| 193 | b1 == 0 when ... \|\| ... is false |
616+
| 193 | b1 == 0 when b1 is false |
617+
| 193 | b1 == 1 when b1 is true |
618+
| 193 | b2 != 0 when b2 is true |
619+
| 193 | b2 != 1 when ... \|\| ... is false |
620+
| 193 | b2 != 1 when b2 is false |
621+
| 193 | b2 == 0 when ... \|\| ... is false |
622+
| 193 | b2 == 0 when b2 is false |
623+
| 193 | b2 == 1 when b2 is true |
580624
| 198 | ! ... != 0 when ! ... is true |
581625
| 198 | ! ... != 0 when b is false |
582626
| 198 | ! ... != 1 when ! ... is false |

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,19 @@
130130
| test.cpp:168:8:168:8 | b | false | 168 | 170 |
131131
| test.cpp:176:7:176:8 | ! ... | true | 176 | 178 |
132132
| test.cpp:176:8:176:8 | c | false | 176 | 178 |
133+
| test.cpp:182:6:182:16 | ! ... | false | 185 | 188 |
134+
| test.cpp:182:6:182:16 | ! ... | true | 182 | 184 |
135+
| test.cpp:182:8:182:9 | b1 | true | 181 | 182 |
136+
| test.cpp:182:8:182:9 | b1 | true | 182 | 182 |
137+
| test.cpp:182:8:182:15 | ... && ... | false | 182 | 184 |
138+
| test.cpp:182:8:182:15 | ... && ... | true | 181 | 182 |
139+
| test.cpp:182:8:182:15 | ... && ... | true | 185 | 188 |
140+
| test.cpp:182:14:182:15 | b2 | true | 181 | 182 |
141+
| test.cpp:193:6:193:16 | ! ... | false | 197 | 199 |
142+
| test.cpp:193:6:193:16 | ! ... | true | 193 | 196 |
143+
| test.cpp:193:8:193:9 | b1 | false | 192 | 193 |
144+
| test.cpp:193:8:193:9 | b1 | false | 193 | 193 |
145+
| test.cpp:193:8:193:15 | ... \|\| ... | false | 192 | 193 |
146+
| test.cpp:193:8:193:15 | ... \|\| ... | false | 193 | 196 |
147+
| test.cpp:193:8:193:15 | ... \|\| ... | true | 197 | 199 |
148+
| test.cpp:193:14:193:15 | b2 | false | 192 | 193 |

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,71 @@ unary
636636
| test.cpp:176:8:176:8 | c | test.cpp:176:7:176:8 | ! ... | == | 1 | 176 | 178 |
637637
| test.cpp:176:8:176:8 | c | test.cpp:176:8:176:8 | c | != | 1 | 176 | 178 |
638638
| test.cpp:176:8:176:8 | c | test.cpp:176:8:176:8 | c | == | 0 | 176 | 178 |
639+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:6:182:16 | ! ... | != | 0 | 182 | 184 |
640+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:6:182:16 | ! ... | != | 1 | 185 | 188 |
641+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:6:182:16 | ! ... | == | 0 | 185 | 188 |
642+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:6:182:16 | ! ... | == | 1 | 182 | 184 |
643+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:8:182:15 | ... && ... | != | 0 | 185 | 188 |
644+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:8:182:15 | ... && ... | != | 1 | 182 | 184 |
645+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:8:182:15 | ... && ... | == | 0 | 182 | 184 |
646+
| test.cpp:182:6:182:16 | ! ... | test.cpp:182:8:182:15 | ... && ... | == | 1 | 185 | 188 |
647+
| test.cpp:182:8:182:9 | b1 | test.cpp:182:8:182:9 | b1 | != | 0 | 181 | 182 |
648+
| test.cpp:182:8:182:9 | b1 | test.cpp:182:8:182:9 | b1 | != | 0 | 182 | 182 |
649+
| test.cpp:182:8:182:9 | b1 | test.cpp:182:8:182:9 | b1 | == | 1 | 181 | 182 |
650+
| test.cpp:182:8:182:9 | b1 | test.cpp:182:8:182:9 | b1 | == | 1 | 182 | 182 |
651+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:6:182:16 | ! ... | != | 0 | 182 | 184 |
652+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:6:182:16 | ! ... | != | 1 | 181 | 182 |
653+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:6:182:16 | ! ... | != | 1 | 185 | 188 |
654+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:6:182:16 | ! ... | == | 0 | 181 | 182 |
655+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:6:182:16 | ! ... | == | 0 | 185 | 188 |
656+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:6:182:16 | ! ... | == | 1 | 182 | 184 |
657+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:9 | b1 | != | 0 | 181 | 182 |
658+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:9 | b1 | != | 0 | 185 | 188 |
659+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:9 | b1 | == | 1 | 181 | 182 |
660+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:9 | b1 | == | 1 | 185 | 188 |
661+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:15 | ... && ... | != | 0 | 181 | 182 |
662+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:15 | ... && ... | != | 0 | 185 | 188 |
663+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:15 | ... && ... | != | 1 | 182 | 184 |
664+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:15 | ... && ... | == | 0 | 182 | 184 |
665+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:15 | ... && ... | == | 1 | 181 | 182 |
666+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:8:182:15 | ... && ... | == | 1 | 185 | 188 |
667+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:14:182:15 | b2 | != | 0 | 181 | 182 |
668+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:14:182:15 | b2 | != | 0 | 185 | 188 |
669+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:14:182:15 | b2 | == | 1 | 181 | 182 |
670+
| test.cpp:182:8:182:15 | ... && ... | test.cpp:182:14:182:15 | b2 | == | 1 | 185 | 188 |
671+
| test.cpp:182:14:182:15 | b2 | test.cpp:182:14:182:15 | b2 | != | 0 | 181 | 182 |
672+
| test.cpp:182:14:182:15 | b2 | test.cpp:182:14:182:15 | b2 | == | 1 | 181 | 182 |
673+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:6:193:16 | ! ... | != | 0 | 193 | 196 |
674+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:6:193:16 | ! ... | != | 1 | 197 | 199 |
675+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:6:193:16 | ! ... | == | 0 | 197 | 199 |
676+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:6:193:16 | ! ... | == | 1 | 193 | 196 |
677+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:8:193:15 | ... \|\| ... | != | 0 | 197 | 199 |
678+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:8:193:15 | ... \|\| ... | != | 1 | 193 | 196 |
679+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:8:193:15 | ... \|\| ... | == | 0 | 193 | 196 |
680+
| test.cpp:193:6:193:16 | ! ... | test.cpp:193:8:193:15 | ... \|\| ... | == | 1 | 197 | 199 |
681+
| test.cpp:193:8:193:9 | b1 | test.cpp:193:8:193:9 | b1 | != | 1 | 192 | 193 |
682+
| test.cpp:193:8:193:9 | b1 | test.cpp:193:8:193:9 | b1 | != | 1 | 193 | 193 |
683+
| test.cpp:193:8:193:9 | b1 | test.cpp:193:8:193:9 | b1 | == | 0 | 192 | 193 |
684+
| test.cpp:193:8:193:9 | b1 | test.cpp:193:8:193:9 | b1 | == | 0 | 193 | 193 |
685+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:6:193:16 | ! ... | != | 0 | 192 | 193 |
686+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:6:193:16 | ! ... | != | 0 | 193 | 196 |
687+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:6:193:16 | ! ... | != | 1 | 197 | 199 |
688+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:6:193:16 | ! ... | == | 0 | 197 | 199 |
689+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:6:193:16 | ! ... | == | 1 | 192 | 193 |
690+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:6:193:16 | ! ... | == | 1 | 193 | 196 |
691+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:9 | b1 | != | 1 | 192 | 193 |
692+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:9 | b1 | != | 1 | 193 | 196 |
693+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:9 | b1 | == | 0 | 192 | 193 |
694+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:9 | b1 | == | 0 | 193 | 196 |
695+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:15 | ... \|\| ... | != | 0 | 197 | 199 |
696+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:15 | ... \|\| ... | != | 1 | 192 | 193 |
697+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:15 | ... \|\| ... | != | 1 | 193 | 196 |
698+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:15 | ... \|\| ... | == | 0 | 192 | 193 |
699+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:15 | ... \|\| ... | == | 0 | 193 | 196 |
700+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:8:193:15 | ... \|\| ... | == | 1 | 197 | 199 |
701+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:14:193:15 | b2 | != | 1 | 192 | 193 |
702+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:14:193:15 | b2 | != | 1 | 193 | 196 |
703+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:14:193:15 | b2 | == | 0 | 192 | 193 |
704+
| test.cpp:193:8:193:15 | ... \|\| ... | test.cpp:193:14:193:15 | b2 | == | 0 | 193 | 196 |
705+
| test.cpp:193:14:193:15 | b2 | test.cpp:193:14:193:15 | b2 | != | 1 | 192 | 193 |
706+
| test.cpp:193:14:193:15 | b2 | test.cpp:193:14:193:15 | b2 | == | 0 | 192 | 193 |

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,26 @@ void test_with_negated_binary_relational(int a, int b) {
176176
if (!c) {
177177

178178
}
179+
}
180+
181+
void test_logical_and(bool b1, bool b2) {
182+
if(!(b1 && b2)) {
183+
use(b1);
184+
use(b2);
185+
} else {
186+
// b1 = true and b2 = true
187+
use(b1);
188+
use(b2);
189+
}
190+
}
191+
192+
void test_logical_or(bool b1, bool b2) {
193+
if(!(b1 || b2)) {
194+
// b1 = false and b2 = false
195+
use(b1);
196+
use(b2);
197+
} else {
198+
use(b1);
199+
use(b2);
200+
}
179201
}

0 commit comments

Comments
 (0)