Branch data Line data Source code
1 : : #include "sute.h"
2 : :
3 : 2 : Return test0024_1(void)
4 : : {
5 : 2 : INITTEST;
6 : :
7 : 2 : create(char,pattern);
8 : :
9 : : // Create memory for the result
10 : 2 : create(char,result);
11 : :
12 : : /*
13 : : * Checking how paths are handled when the directory name starts
14 : : * with an apostrophe
15 : : */
16 : 2 : const char *arguments = "--progress --database=database1.db "
17 : : "tests/fixtures/\\'apostrophe";
18 : :
19 : 2 : const char *filename = "templates/0024_001.txt";
20 : :
21 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
22 : :
23 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
24 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
25 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
26 : :
27 : : // Clean to use it iteratively
28 : 2 : del(pattern);
29 : 2 : del(result);
30 : :
31 : : // Clean up test results
32 : 2 : const char *command = "cd ${TMPDIR};"
33 : : "rm database1.db;";
34 : :
35 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
36 : :
37 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
38 : : }
39 : :
40 : 2 : Return test0024_2(void)
41 : : {
42 : 2 : INITTEST;
43 : :
44 : 2 : create(char,pattern);
45 : :
46 : : // Create memory for the result
47 : 2 : create(char,result);
48 : :
49 : : /*
50 : : * Checking how paths are handled when the directory name ends
51 : : * with an apostrophe
52 : : */
53 : 2 : const char *arguments = "--progress --database=database1.db tests/fixtures/apostrophe\\'";
54 : :
55 : 2 : const char *filename = "templates/0024_002.txt";
56 : :
57 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
58 : :
59 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
60 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
61 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
62 : :
63 : : // Clean to use it iteratively
64 : 2 : del(pattern);
65 : 2 : del(result);
66 : :
67 : : // Clean up test results
68 : 2 : const char *command = "cd ${TMPDIR};"
69 : : "rm database1.db;";
70 : :
71 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
72 : :
73 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
74 : : }
75 : :
76 : : /**
77 : : * Stage 1. Adding:
78 : : * precizer --progress --database=database1.db tests/fixtures/\'apostrophe/\'apostrophe/
79 : : * Stage 2. Adding:
80 : : * precizer --progress --database=database2.db tests/fixtures/apostrophe\'/\'apostrophe/apostrophe\'/
81 : : * Final stage. Comparing:
82 : : * precizer --compare database1.db database2.db
83 : : */
84 : 2 : static Return test0024_3(void)
85 : : {
86 : 2 : INITTEST;
87 : :
88 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
89 : :
90 : 2 : const char *arguments = "--progress --database=database1.db "
91 : : "tests/fixtures/\\'apostrophe/\\'apostrophe/";
92 : :
93 : : // Create memory for the result
94 : 2 : create(char,result);
95 : 2 : create(char,chunk);
96 : :
97 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
98 : :
99 [ + - + - ]: 2 : ASSERT(SUCCESS == copy(result,chunk));
100 : :
101 : 2 : arguments = "--progress --database=database2.db "
102 : : "tests/fixtures/apostrophe\\'/\\'apostrophe/apostrophe\\'/";
103 : :
104 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
105 : :
106 [ + - + - ]: 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
107 : :
108 : 2 : arguments = "--compare database1.db database2.db";
109 : :
110 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
111 : :
112 [ + - + - ]: 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
113 : :
114 : : // Create memory for the result
115 : 2 : create(char,pattern);
116 : :
117 : 2 : const char *filename = "templates/0024_003.txt";
118 : :
119 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
120 : :
121 : : // Match the result against the pattern
122 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
123 : :
124 : : // Clean up test results
125 : 2 : const char *command = "cd ${TMPDIR};"
126 : : "rm database1.db database2.db";
127 : :
128 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
129 : :
130 : 2 : del(pattern);
131 : 2 : del(chunk);
132 : 2 : del(result);
133 : :
134 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
135 : : }
136 : :
137 : : // Main test runner
138 : 2 : Return test0024(void)
139 : : {
140 : 2 : INITTEST;
141 : :
142 [ + - ]: 2 : TEST(test0024_1,"Prefix path with apostrophe…");
143 [ + - ]: 2 : TEST(test0024_2,"Another prefix and apostrophe combination in the name…");
144 [ + - ]: 2 : TEST(test0024_3,"Adding and comparing with apostrophe…");
145 : :
146 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
147 : : }
|