Skip to content

Commit bd09aad

Browse files
committed
C++: Add tests.
1 parent e360800 commit bd09aad

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

cpp/ql/test/library-tests/dataflow/dataflow-tests/test-source-sink.expected

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ astFlow
147147
| test.cpp:1165:10:1165:15 | call to source | test.cpp:1239:10:1239:26 | * ... |
148148
| test.cpp:1195:10:1195:24 | call to indirect_source | test.cpp:1200:19:1200:36 | global_int_ptr_ptr |
149149
| test.cpp:1195:10:1195:24 | call to indirect_source | test.cpp:1201:10:1201:27 | global_int_ptr_ptr |
150+
| test.cpp:1258:11:1258:16 | call to source | test.cpp:1259:8:1259:10 | ... ++ |
151+
| test.cpp:1262:7:1262:12 | call to source | test.cpp:1263:8:1263:10 | ... -- |
152+
| test.cpp:1266:7:1266:12 | call to source | test.cpp:1267:8:1267:10 | ++ ... |
153+
| test.cpp:1266:7:1266:12 | call to source | test.cpp:1268:8:1268:8 | x |
154+
| test.cpp:1270:7:1270:12 | call to source | test.cpp:1271:8:1271:10 | -- ... |
155+
| test.cpp:1270:7:1270:12 | call to source | test.cpp:1272:8:1272:8 | x |
156+
| test.cpp:1274:7:1274:12 | call to source | test.cpp:1275:8:1275:14 | ... += ... |
157+
| test.cpp:1274:7:1274:12 | call to source | test.cpp:1276:8:1276:8 | x |
158+
| test.cpp:1278:7:1278:12 | call to source | test.cpp:1279:8:1279:14 | ... -= ... |
159+
| test.cpp:1278:7:1278:12 | call to source | test.cpp:1280:8:1280:8 | x |
160+
| test.cpp:1284:11:1284:16 | call to source | test.cpp:1285:8:1285:20 | ... ? ... : ... |
161+
| test.cpp:1288:7:1288:12 | call to source | test.cpp:1289:8:1289:20 | ... ++ |
162+
| test.cpp:1288:7:1288:12 | call to source | test.cpp:1290:8:1290:8 | x |
163+
| test.cpp:1292:7:1292:12 | call to source | test.cpp:1294:8:1294:8 | x |
164+
| test.cpp:1296:7:1296:12 | call to source | test.cpp:1297:8:1297:18 | ... ? ... : ... |
165+
| test.cpp:1296:7:1296:12 | call to source | test.cpp:1298:8:1298:8 | x |
166+
| test.cpp:1300:7:1300:12 | call to source | test.cpp:1301:8:1301:18 | ... ? ... : ... |
167+
| test.cpp:1300:7:1300:12 | call to source | test.cpp:1302:8:1302:8 | x |
168+
| test.cpp:1304:7:1304:12 | call to source | test.cpp:1305:8:1305:18 | ... ? ... : ... |
169+
| test.cpp:1304:7:1304:12 | call to source | test.cpp:1306:8:1306:8 | x |
170+
| test.cpp:1308:7:1308:12 | call to source | test.cpp:1309:14:1309:16 | ... ++ |
171+
| test.cpp:1312:7:1312:12 | call to source | test.cpp:1313:8:1313:24 | ... ? ... : ... |
172+
| test.cpp:1312:7:1312:12 | call to source | test.cpp:1314:8:1314:8 | x |
150173
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
151174
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |
152175
| true_upon_entry.cpp:33:11:33:16 | call to source | true_upon_entry.cpp:39:8:39:8 | x |
@@ -354,6 +377,19 @@ irFlow
354377
| test.cpp:1195:10:1195:24 | *call to indirect_source | test.cpp:1218:19:1218:36 | **global_int_ptr_ptr |
355378
| test.cpp:1195:10:1195:24 | *call to indirect_source | test.cpp:1224:19:1224:37 | ** ... |
356379
| test.cpp:1195:10:1195:24 | *call to indirect_source | test.cpp:1227:10:1227:29 | * ... |
380+
| test.cpp:1258:11:1258:16 | call to source | test.cpp:1259:8:1259:10 | ... ++ |
381+
| test.cpp:1262:7:1262:12 | call to source | test.cpp:1263:8:1263:10 | ... -- |
382+
| test.cpp:1284:11:1284:16 | call to source | test.cpp:1285:8:1285:20 | ... ? ... : ... |
383+
| test.cpp:1288:7:1288:12 | call to source | test.cpp:1290:8:1290:8 | x |
384+
| test.cpp:1292:7:1292:12 | call to source | test.cpp:1294:8:1294:8 | x |
385+
| test.cpp:1296:7:1296:12 | call to source | test.cpp:1297:8:1297:18 | ... ? ... : ... |
386+
| test.cpp:1296:7:1296:12 | call to source | test.cpp:1298:8:1298:8 | x |
387+
| test.cpp:1300:7:1300:12 | call to source | test.cpp:1301:8:1301:18 | ... ? ... : ... |
388+
| test.cpp:1300:7:1300:12 | call to source | test.cpp:1302:8:1302:8 | x |
389+
| test.cpp:1304:7:1304:12 | call to source | test.cpp:1306:8:1306:8 | x |
390+
| test.cpp:1308:7:1308:12 | call to source | test.cpp:1309:8:1309:16 | ... ++ |
391+
| test.cpp:1312:7:1312:12 | call to source | test.cpp:1313:8:1313:24 | ... ? ... : ... |
392+
| test.cpp:1312:7:1312:12 | call to source | test.cpp:1314:8:1314:8 | x |
357393
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |
358394
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
359395
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |

cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,4 +1252,64 @@ namespace globals_without_explicit_def {
12521252
calls_set_array();
12531253
sink(*global_int_array); // $ ir MISSING: ast
12541254
}
1255+
}
1256+
1257+
void crement_test1() {
1258+
int x = source();
1259+
sink(x++); // $ ir ast
1260+
sink(x);
1261+
1262+
x = source();
1263+
sink(x--); // $ ir ast
1264+
sink(x);
1265+
1266+
x = source();
1267+
sink(++x); // $ SPURIOUS: ast
1268+
sink(x); // $ SPURIOUS: ast
1269+
1270+
x = source();
1271+
sink(--x); // $ SPURIOUS: ast
1272+
sink(x); // $ SPURIOUS: ast
1273+
1274+
x = source();
1275+
sink(x += 10); // $ SPURIOUS: ast
1276+
sink(x); // $ SPURIOUS: ast
1277+
1278+
x = source();
1279+
sink(x -= 10); // $ SPURIOUS: ast
1280+
sink(x); // $ SPURIOUS: ast
1281+
}
1282+
1283+
void crement_test2(bool b, int y) {
1284+
int x = source();
1285+
sink(b ? x++ : x--); // $ ir ast
1286+
sink(x);
1287+
1288+
x = source();
1289+
sink((b ? x : y)++); // $ ast MISSING: ir
1290+
sink(x); // $ ir ast
1291+
1292+
x = source();
1293+
sink(++(b ? x : y));
1294+
sink(x); // $ ir ast
1295+
1296+
x = source();
1297+
sink(b ? x++ : y); // $ ir ast
1298+
sink(x); // $ ir ast
1299+
1300+
x = source();
1301+
sink(b ? x : y++); // $ ir ast
1302+
sink(x); // $ ir ast
1303+
1304+
x = source();
1305+
sink(b ? ++x : y); // $ SPURIOUS: ast
1306+
sink(x); // $ ir ast
1307+
1308+
x = source();
1309+
sink((long)x++); // $ ir ast
1310+
sink(x);
1311+
1312+
x = source();
1313+
sink(b ? (long)x++ : 0); // $ ir ast
1314+
sink(x); // $ ir ast
12551315
}

0 commit comments

Comments
 (0)