main
test-branch
| Line | |
|---|
| 1 | /* fileOpen: an example for covering CIVL code. The example may not be
|
|---|
| 2 | understandable for human beings. The main purpose is testing
|
|---|
| 3 | different forms of char array or pointer to char as an argument of
|
|---|
| 4 | a function expecting the "char *" type. */
|
|---|
| 5 |
|
|---|
| 6 | #include<civlc.cvh>
|
|---|
| 7 | #include<stdio.h>
|
|---|
| 8 | #include<civl-stdio.cvh>
|
|---|
| 9 |
|
|---|
| 10 | $input int x;
|
|---|
| 11 | $input int y;
|
|---|
| 12 | $input char ncaFilename[y];
|
|---|
| 13 | $input char icaFilename[];
|
|---|
| 14 | $assume(x < 10);
|
|---|
| 15 | $assume(y > 10);
|
|---|
| 16 | void main(){
|
|---|
| 17 | char filename[10] = "dummyfile";
|
|---|
| 18 | char c = 'c';
|
|---|
| 19 | FILE *file0 = fopen(&filename[4], "r");
|
|---|
| 20 | int a[5];
|
|---|
| 21 | int count = fscanf(file0, "%d", a);
|
|---|
| 22 | int fooLength = $text_file_length("foo");
|
|---|
| 23 |
|
|---|
| 24 | #ifdef NCINDEX //non-concrete index
|
|---|
| 25 | FILE *file1 = fopen(&filename[x], "r");
|
|---|
| 26 | #elif defined NCARRAY //array with non-concrete extent
|
|---|
| 27 | FILE *file1 = fopen(&ncaFilename[2], "r");
|
|---|
| 28 | #elif defined NEGINDEX //negative index
|
|---|
| 29 | FILE *file1 = fopen((&filename[-1]), "r");
|
|---|
| 30 | #elif defined SCHAR //single char
|
|---|
| 31 | FILE *file1 = fopen(&c, "r");
|
|---|
| 32 | #else //incomplete array
|
|---|
| 33 | FILE *file1 = fopen(&icaFilename[2], "r");
|
|---|
| 34 | #endif
|
|---|
| 35 | $free(file0);
|
|---|
| 36 | $free(file1);
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.