File tree 14 files changed +259
-0
lines changed 14 files changed +259
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ enum my_enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ };
11
+
12
+ int main ()
13
+ {
14
+ enum my_enum ev1 ;
15
+ enum my_enum ev2 ;
16
+ ev1 = first ;
17
+ ev2 = fifth ;
18
+ int i = 0 ;
19
+ while (i < 10 )
20
+ {
21
+ ev1 ++ ;
22
+ assert (__CPROVER_enum_is_in_range (i ));
23
+ i ++ ;
24
+ }
25
+ return 0 ;
26
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test10.c
3
+
4
+ ^EXIT=(6|70)$
5
+ ^SIGNAL=0$
6
+ ^file enum_test10.c line \d+ function main: __CPROVER_enum_is_in_range expects enum, but \(i\) has type `signed int`$
7
+ --
8
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(i\): SUCCESS$
9
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(i\): FAILURE$
10
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$
11
+ --
12
+ This test the type checking of argument for __CPROVER_enum_is_in_range
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ enum my_enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ };
11
+
12
+ int main ()
13
+ {
14
+ enum my_enum ev1 ;
15
+ enum my_enum ev2 ;
16
+ ev1 = first ;
17
+ ev2 = fifth ;
18
+ assert (__CPROVER_enum_is_in_range (ev1 , ev2 ));
19
+ return 0 ;
20
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test12.c
3
+
4
+ ^EXIT=(6|70)$
5
+ ^SIGNAL=0$
6
+ ^file enum_test12.c line \d+ function main: __CPROVER_enum_is_in_range takes exactly 1 argument, but 2 were provided$
7
+ --
8
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(.*\): SUCCESS$
9
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(.*\): FAILURE$
10
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$
11
+ --
12
+ This test the type checking of argument for __CPROVER_enum_is_in_range
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ enum my_enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ };
11
+
12
+ int main ()
13
+ {
14
+ enum my_enum ev1 ;
15
+ enum my_enum ev2 ;
16
+ ev1 = first ;
17
+ ev2 = fifth ;
18
+ while (ev1 != ev2 )
19
+ {
20
+ ev1 ++ ;
21
+ assert (__CPROVER_enum_is_in_range (ev1 ));
22
+ }
23
+ return 0 ;
24
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test3.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS
7
+ --
8
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range
9
+ --
10
+ This test is for the enum_is_in_range working properly, the negation
11
+ is if the function is not defined.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ enum my_enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ };
11
+
12
+ int main ()
13
+ {
14
+ enum my_enum ev1 ;
15
+ enum my_enum ev2 ;
16
+ ev1 = first ;
17
+ ev2 = fifth ;
18
+ int i = 0 ;
19
+ while (i < 10 )
20
+ {
21
+ ev1 ++ ;
22
+ assert (__CPROVER_enum_is_in_range (ev1 ));
23
+ i ++ ;
24
+ }
25
+ return 0 ;
26
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test4.c
3
+
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): FAILURE$
7
+ --
8
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS$
9
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$
10
+ --
11
+ This test is for the enum_is_in_range working properly and detecting
12
+ when the enum is not in range. The negation tests are to ensure the
13
+ out of range is detected, and if the function is not defined.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ enum my_enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ };
11
+
12
+ void testfun (enum my_enum ee )
13
+ {
14
+ }
15
+
16
+ int main ()
17
+ {
18
+ enum my_enum ev1 ;
19
+ enum my_enum ev2 ;
20
+ __CPROVER_assume (__CPROVER_enum_is_in_range (ev1 ));
21
+ enum my_enum ev3 = ev1 ;
22
+ testfun (ev3 );
23
+ testfun (ev2 );
24
+ return 0 ;
25
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test5.c
3
+ --enum-range-check
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^\[main.enum-range-check.6\] line \d+ enum range check in ev3: SUCCESS$
7
+ ^\[main.enum-range-check.7\] line \d+ enum range check in ev2: FAILURE$
8
+ --
9
+ ^\[main.enum-range-check.6\] line \d+ enum range check in ev3: FAILURE$
10
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$
11
+ --
12
+ This test is for the enum_is_in_range working in assume statements
13
+ (and also value passing through assignments of enums). The failure
14
+ test case is checking that range checks do work on enums.
15
+ The negation tests are to ensure the assumption is taken into account
16
+ for ev1 and thus ev3, and if the function is not defined.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ typedef enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ } my_enum ;
11
+
12
+ int main ()
13
+ {
14
+ my_enum ev1 ;
15
+ my_enum ev2 ;
16
+ ev1 = first ;
17
+ ev2 = fifth ;
18
+ while (!(ev1 == ev2 ))
19
+ {
20
+ ev1 ++ ;
21
+ assert (__CPROVER_enum_is_in_range (ev1 ));
22
+ }
23
+ return 0 ;
24
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test7.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS
7
+ --
8
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range
9
+ --
10
+ This test is for the enum_is_in_range working properly, the negation
11
+ is if the function is not defined.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ typedef enum
4
+ {
5
+ first ,
6
+ second ,
7
+ third ,
8
+ fourth ,
9
+ fifth
10
+ } my_enum ;
11
+
12
+ int main ()
13
+ {
14
+ my_enum ev1 ;
15
+ my_enum ev2 ;
16
+ ev1 = first ;
17
+ ev2 = fifth ;
18
+ int i = 0 ;
19
+ while (i < 10 )
20
+ {
21
+ ev1 ++ ;
22
+ assert (__CPROVER_enum_is_in_range (ev1 ));
23
+ i ++ ;
24
+ }
25
+ return 0 ;
26
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ enum_test8.c
3
+
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): FAILURE$
7
+ --
8
+ ^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS$
9
+ ^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$
10
+ --
11
+ This test is for the enum_is_in_range working properly and detecting
12
+ when the enum is not in range. The negation tests are to ensure the
13
+ out of range is detected, and if the function is not defined.
You can’t perform that action at this time.
0 commit comments