Line data Source code
1 : #include "sute.h"
2 :
3 2 : Return test0018_1_maxdepth_argument(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 : ASSERT(SUCCESS == runit("--maxdepth=3 --database=database3.db $TMPDIR/tests/examples/levels",result,COMPLETED,ALLOW_BOTH));
17 :
18 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
19 :
20 : // Match the result against the pattern
21 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
22 :
23 : // Clean to use it iteratively
24 2 : del(pattern);
25 2 : del(result);
26 :
27 : #if 0
28 : echo(STDOUT,"%s\n",getcstring(result));
29 : #endif
30 :
31 : /* File system traversal with unlimited depth */
32 2 : filename = "templates/0018_001_2.txt";
33 :
34 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
35 :
36 2 : ASSERT(SUCCESS == runit("--update --database=database3.db $TMPDIR/tests/examples/levels",result,COMPLETED,ALLOW_BOTH));
37 :
38 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
39 :
40 : // Match the result against the pattern
41 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
42 :
43 : // Clean to use it iteratively
44 2 : del(pattern);
45 2 : del(result);
46 :
47 : // Clean up test results
48 2 : ASSERT(SUCCESS == external_call("rm \"${TMPDIR}/database3.db\"",COMPLETED,ALLOW_BOTH));
49 2 : RETURN_STATUS;
50 : }
51 :
52 2 : Return test0018_2_comparing_templates(void)
53 : {
54 2 : INITTEST;
55 :
56 2 : create(char,text1);
57 2 : create(char,text2);
58 2 : char *diff = NULL;
59 2 : create(char,pattern);
60 2 : const char *filename = NULL;
61 :
62 : /* 0018 001 */
63 2 : ASSERT(SUCCESS == get_file_content("templates/0018_001_1.txt",text1));
64 :
65 2 : ASSERT(SUCCESS == get_file_content("templates/0018_001_2.txt",text2));
66 :
67 2 : ASSERT(SUCCESS == compare_strings(&diff,getcstring(text1),getcstring(text2)));
68 :
69 2 : filename = "templates/0018_002_1.txt";
70 :
71 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
72 2 : create(char,diff_buffer);
73 2 : ASSERT(SUCCESS == copy_literal(diff_buffer,diff));
74 2 : ASSERT(SUCCESS == match_pattern(diff_buffer,pattern,filename));
75 :
76 2 : del(text1);
77 2 : del(text2);
78 2 : reset(&diff);
79 2 : del(pattern);
80 2 : del(diff_buffer);
81 :
82 2 : RETURN_STATUS;
83 : }
84 :
85 : /**
86 : *
87 : * --maxdepth argument testing
88 : *
89 : */
90 2 : Return test0018(void)
91 : {
92 2 : INITTEST;
93 :
94 2 : TEST(test0018_1_maxdepth_argument,"Traversal with limited depth…")
95 2 : TEST(test0018_2_comparing_templates,"Comparing templates w/ and w/o depth limits…")
96 :
97 2 : RETURN_STATUS;
98 : }
|