Branch data Line data Source code
1 : : #include "sute.h"
2 : :
3 : 2 : Return test0018_1(void)
4 : : {
5 : 2 : INITTEST;
6 : :
7 : : /* File system traversal with a maximum depth of 3 */
8 : 2 : create(char,result);
9 : :
10 : 2 : create(char,pattern);
11 : :
12 : 2 : const char *filename = "templates/0018_001_1.txt";
13 : :
14 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
15 : :
16 : 2 : const char *arguments = "--maxdepth=3 --database=database3.db "
17 : : "$TMPDIR/tests/fixtures/levels";
18 : :
19 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
20 : :
21 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
22 : :
23 : : // Match the result against the pattern
24 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
25 : :
26 : : // Clean to use it iteratively
27 : 2 : del(pattern);
28 : 2 : del(result);
29 : :
30 : : #if 0
31 : : echo(STDOUT,"%s\n",getcstring(result));
32 : : #endif
33 : :
34 : : /* File system traversal with unlimited depth */
35 : 2 : filename = "templates/0018_001_2.txt";
36 : :
37 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
38 : :
39 : 2 : arguments = "--database=database4.db "
40 : : "$TMPDIR/tests/fixtures/levels";
41 : :
42 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
43 : :
44 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
45 : :
46 : : // Match the result against the pattern
47 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
48 : :
49 : : // Clean to use it iteratively
50 : 2 : del(pattern);
51 : 2 : del(result);
52 : :
53 : : // Clean up test results
54 : 2 : const char *command = "rm \"${TMPDIR}/database4.db\"";
55 : :
56 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
57 : :
58 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
59 : : }
60 : :
61 : 2 : Return test0018_2(void)
62 : : {
63 : 2 : INITTEST;
64 : :
65 : : /* File system traversal with a maximum depth of 3 */
66 : 2 : create(char,result);
67 : 2 : create(char,pattern);
68 : :
69 : : /* File system traversal with unlimited depth */
70 : 2 : const char *filename = "templates/0018_002.txt";
71 : :
72 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
73 : :
74 : 2 : const char *arguments = "--update --database=database3.db "
75 : : "$TMPDIR/tests/fixtures/levels";
76 : :
77 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
78 : :
79 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
80 : :
81 : : // Match the result against the pattern
82 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
83 : :
84 : : // Clean to use it iteratively
85 : 2 : del(pattern);
86 : 2 : del(result);
87 : :
88 : : // Clean up test results
89 : 2 : const char *command = "rm \"${TMPDIR}/database3.db\"";
90 : :
91 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
92 : :
93 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
94 : : }
95 : :
96 : :
97 : 2 : Return test0018_3(void)
98 : : {
99 : 2 : INITTEST;
100 : :
101 : 2 : create(char,text1);
102 : 2 : create(char,text2);
103 : 2 : create(char,pattern);
104 : 2 : create(char,diff_buffer);
105 : 2 : char *diff = NULL;
106 : :
107 : : /* 0018 001 */
108 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content("templates/0018_001_1.txt",text1));
109 : :
110 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content("templates/0018_001_2.txt",text2));
111 : :
112 [ + - + - ]: 2 : ASSERT(SUCCESS == compare_strings(&diff,getcstring(text1),getcstring(text2)));
113 : :
114 : 2 : const char *filename = "templates/0018_003.txt";
115 : :
116 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
117 [ + - + - ]: 2 : ASSERT(SUCCESS == copy_literal(diff_buffer,diff));
118 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(diff_buffer,pattern,filename));
119 : :
120 : 2 : del(text1);
121 : 2 : del(text2);
122 : 2 : del(pattern);
123 : 2 : del(diff_buffer);
124 : 2 : reset(&diff);
125 : :
126 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
127 : : }
128 : :
129 : 2 : Return test0018_4(void)
130 : : {
131 : 2 : INITTEST;
132 : :
133 : 2 : create(char,text1);
134 : 2 : create(char,text2);
135 : 2 : create(char,pattern);
136 : 2 : create(char,diff_buffer);
137 : 2 : char *diff = NULL;
138 : :
139 : : /* 0018 001 */
140 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content("templates/0018_001_1.txt",text1));
141 : :
142 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content("templates/0018_002.txt",text2));
143 : :
144 [ + - + - ]: 2 : ASSERT(SUCCESS == compare_strings(&diff,getcstring(text1),getcstring(text2)));
145 : :
146 : 2 : const char *filename = "templates/0018_004.txt";
147 : :
148 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
149 [ + - + - ]: 2 : ASSERT(SUCCESS == copy_literal(diff_buffer,diff));
150 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(diff_buffer,pattern,filename));
151 : :
152 : 2 : del(text1);
153 : 2 : del(text2);
154 : 2 : del(pattern);
155 : 2 : del(diff_buffer);
156 : 2 : reset(&diff);
157 : :
158 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
159 : : }
160 : :
161 : : /**
162 : : *
163 : : * --maxdepth argument testing
164 : : *
165 : : */
166 : 2 : Return test0018(void)
167 : : {
168 : 2 : INITTEST;
169 : :
170 [ + - ]: 2 : TEST(test0018_1,"Traversal with limited depth…");
171 [ + - ]: 2 : TEST(test0018_2,"Update DB w/o depth limits…");
172 [ + - ]: 2 : TEST(test0018_3,"Comparing templates w/ and w/o depth limits…")
173 [ + - ]: 2 : TEST(test0018_4,"Comparing templates after update w/o depth limits…")
174 : :
175 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
176 : : }
|