-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.h
executable file
·77 lines (69 loc) · 2.92 KB
/
tests.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* The file belongs to task 4 of SFT Lab
* No need to change.
*
* - specifies the test values of types FILE* and const char*
* - make sure that you test all combinations of all test values
* - if you are unsure about a meaning of a test value specification,
* then read the task description, use the forum or ask us
* - use the functions specified by tools.h to create appropriate test values
*/
#ifndef _TESTS_H_
#define _TESTS_H_
#include <stdio.h>
struct TestCase {
int id; // test value id
const char *desc; // descriptive string
int expected_returnvalue; // expected return value of fputs (not used)
};
const TestCase testCases_FILE[] = {
#define TC_FILE_NULL 0
{TC_FILE_NULL, "NULL pointer", EOF},
#define TC_FILE_RONLY 1
{TC_FILE_RONLY, "FILE opened for reading only", EOF},
#define TC_FILE_WONLY 2
{TC_FILE_WONLY, "FILE opened for writing only", 1},
#define TC_FILE_RW 3
{TC_FILE_RW, "FILE opened for reading and writing", 1},
#define TC_FILE_CLOSED 4
{TC_FILE_CLOSED, "FILE already closed", EOF},
#define TC_FILE_MEM_RONLY 5
{TC_FILE_MEM_RONLY, "pointer to valid file structure (memory read only)", EOF},
#define TC_FILE_MEM_WONLY 6
{TC_FILE_MEM_WONLY, "pointer to valid file structure (memory write only)", 1},
#define TC_FILE_MEM_RW 7
{TC_FILE_MEM_RW, "pointer to valid file structure (memory read/write)", 1},
#define TC_FILE_MEM_0_RONLY 8
{TC_FILE_MEM_0_RONLY, "pointer to a \"0\" page (memory read only)", EOF},
#define TC_FILE_MEM_0_WONLY 9
{TC_FILE_MEM_0_WONLY, "pointer to a \"0\" page (memory write only)", EOF},
#define TC_FILE_MEM_0_RW 10
{TC_FILE_MEM_0_RW, "pointer to a \"0\" page (memory read/write)", EOF},
#define TC_FILE_MEM_INACCESSIBLE 11
{TC_FILE_MEM_INACCESSIBLE, "pointer to inaccessible memory", EOF},
};
// number of test values for FILE*
const int testCases_FILE_count = sizeof(testCases_FILE) /
sizeof(testCases_FILE[0]);
const TestCase testCases_CSTR[] = {
#define TC_CSTR_NULL 0
{TC_CSTR_NULL, "NULL pointer", EOF},
#define TC_CSTR_MEM_RONLY 1
{TC_CSTR_MEM_RONLY, "pointer to valid string (memory read only)", 1},
#define TC_CSTR_MEM_WONLY 2
{TC_CSTR_MEM_WONLY, "pointer to valid string (memory write only)", EOF},
#define TC_CSTR_MEM_RW 3
{TC_CSTR_MEM_RW, "pointer to valid string (memory read/write)", 1},
#define TC_CSTR_MEM_0_RONLY 4
{TC_CSTR_MEM_0_RONLY, "pointer to a string without trailing 0 (memory read only)", 1},
#define TC_CSTR_MEM_0_WONLY 5
{TC_CSTR_MEM_0_WONLY, "pointer to a string without trailing 0 (memory write only)", EOF},
#define TC_CSTR_MEM_0_RW 6
{TC_CSTR_MEM_0_RW, "pointer to a string without trailing 0 (memory read/write)", 1},
#define TC_CSTR_MEM_INACCESSIBLE 7
{TC_CSTR_MEM_INACCESSIBLE, "pointer to inaccessible memory", EOF},
};
// number of test values for const char*
const int testCases_CSTR_count = sizeof(testCases_CSTR) /
sizeof(testCases_CSTR[0]);
#endif