Skip to content

Commit 704f1fa

Browse files
committed
C++: Add switches as testcases for guard conditions.
1 parent 693c28a commit 704f1fa

File tree

1 file changed

+34
-0
lines changed
  • cpp/ql/test/library-tests/controlflow/guards

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,37 @@ bool testWithCatch0(int v)
5252

5353
return false;
5454
}
55+
56+
void use1(int);
57+
void use2(int);
58+
void use3(int);
59+
60+
void test_switches_simple(int i) {
61+
switch(i) {
62+
case 0:
63+
use1(i);
64+
break;
65+
case 1:
66+
use2(i);
67+
/* NOTE: fallthrough */
68+
case 2:
69+
use3(i);
70+
}
71+
}
72+
73+
void test_switches_range(int i) {
74+
switch(i) {
75+
case 0 ... 10:
76+
use1(i);
77+
break;
78+
case 11 ... 20:
79+
use2(i);
80+
}
81+
}
82+
83+
void test_switches_default(int i) {
84+
switch(i) {
85+
default:
86+
use1(i);
87+
}
88+
}

0 commit comments

Comments
 (0)