Skip to content

Commit ddf72d1

Browse files
committed
Add tests for strchr
using the string-refinement solver.
1 parent 80c88cc commit ddf72d1

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <assert.h>
2+
#include <string.h>
3+
4+
int main()
5+
{
6+
char test[] = "foo";
7+
8+
char *first_o = strchr(test, 'o');
9+
assert(*first_o == test[1]);
10+
assert(*first_o == test[0]);
11+
char *first_t = strchr(test, 't');
12+
assert(*first_t == test[1]);
13+
assert(*first_t == test[0]);
14+
return 0;
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE broken-smt-backend
2+
test.c
3+
--refine-strings --max-nondet-string-length 10
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main.assertion.\d+\] line \d+ assertion \*first_o == test\[1\]: SUCCESS$
7+
^\[main.assertion.\d+\] line \d+ assertion \*first_o == test\[0\]: FAILURE$
8+
^\[main.assertion.\d+\] line \d+ assertion \*first_t == test\[1\]: FAILURE$
9+
^\[main.assertion.\d+\] line \d+ assertion \*first_t == test\[0\]: FAILURE$
10+
^VERIFICATION FAILED$
11+
--
12+
^warning: ignoring
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <string.h>
3+
4+
int main()
5+
{
6+
int i;
7+
char *test = i ? "fo\0tis" : "notfoti";
8+
9+
char *first_o = strchr(test, 'o');
10+
assert(first_o != NULL);
11+
assert(*first_o == test[0]);
12+
return 0;
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE broken-smt-backend
2+
test.c
3+
--refine-strings
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main.assertion.\d+\] line \d+ assertion first_o != (NULL|\(\(void \*\)0\)): SUCCESS$
7+
^\[main.assertion.\d+\] line \d+ assertion \*first_o == test\[0\]: FAILURE$
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring

0 commit comments

Comments
 (0)