Skip to content

Commit aee9519

Browse files
committed
testsuite: Add x-flow tests
1 parent f614d32 commit aee9519

6 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdlib.h>
2+
3+
// Simple for loop
4+
5+
void f() {
6+
char* buf = (char*) malloc(9);
7+
int i;
8+
for (i = 0; i < 12; i++) {
9+
buf[i] = 's';
10+
}
11+
}
12+
13+
int main() {
14+
f();
15+
return 0;
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdlib.h>
2+
3+
// Simple while loop
4+
5+
void f() {
6+
char* buf = (char*) malloc(9);
7+
int i = 0;
8+
while (i < 12) {
9+
buf[i] = 's';
10+
i++;
11+
}
12+
}
13+
14+
int main() {
15+
f();
16+
return 0;
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdlib.h>
2+
3+
// Reallocation
4+
5+
void f() {
6+
char* buf = (char*) malloc(20);
7+
buf[6] = 'x';
8+
buf = (char*) realloc(buf, 9);
9+
int i = 0;
10+
while (i < 12) {
11+
buf[i] = 's';
12+
i++;
13+
}
14+
}
15+
16+
int main() {
17+
f();
18+
return 0;
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdlib.h>
2+
3+
// Nested loops
4+
5+
void f() {
6+
char* buf = (char*) malloc(9);
7+
int i, j;
8+
for (i = 0; i < 3; i++) {
9+
for (j = 0; j < 6; j++) {
10+
buf[i*j] = 's';
11+
}
12+
}
13+
}
14+
15+
int main() {
16+
f();
17+
return 0;
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdlib.h>
2+
#include <string.h>
3+
4+
// Copy string
5+
6+
void f() {
7+
char* buf = (char*) malloc(9);
8+
strcpy(buf, "Too big to fit");
9+
}
10+
11+
int main() {
12+
f();
13+
return 0;
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdlib.h>
2+
3+
// More complex object
4+
5+
void f() {
6+
struct Person {
7+
const char* name;
8+
int age;
9+
};
10+
Person* people = (Person*) malloc(9 * sizeof(Person));
11+
for (int i = 0; i < 12; i++) {
12+
people[i].name = "John";
13+
people[i].age = 23;
14+
}
15+
}
16+
17+
int main() {
18+
f();
19+
return 0;
20+
}

0 commit comments

Comments
 (0)