This source file includes following definitions.
- guess_message_value
- rand
- setup
- teardown
- START_TEST
- START_PARAMETRIZED_TEST
- main
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 #define TEST_SUITE_NAME "/src/filemanager"
28
29 #include "tests/mctest.h"
30
31 #include "lib/strutil.h"
32 #include "lib/util.h"
33
34 #include "src/filemanager/filemanager.h"
35
36
37
38
39
40
41 char *
42 guess_message_value (void)
43 {
44 return g_strdup ("not_exists");
45 }
46
47
48
49
50 static gboolean rand__return_value = 0;
51
52
53 int
54 rand (void)
55 {
56 return rand__return_value;
57 }
58
59
60
61 static void
62 setup (void)
63 {
64 mc_global.share_data_dir = (char *) TEST_SHARE_DIR;
65 str_init_strings (NULL);
66 }
67
68 static void
69 teardown (void)
70 {
71 str_uninit_strings ();
72 }
73
74
75
76
77 START_TEST (test_not_force)
78
79 {
80
81 char *first_hint_for_ignore;
82 char *actual_hint1;
83 char *actual_hint2;
84 char *actual_hint3;
85
86
87 first_hint_for_ignore = get_random_hint (FALSE);
88 actual_hint1 = get_random_hint (FALSE);
89 actual_hint2 = get_random_hint (FALSE);
90 actual_hint3 = get_random_hint (FALSE);
91
92
93 mctest_assert_ptr_ne (first_hint_for_ignore, NULL);
94 mctest_assert_str_eq (actual_hint1, "");
95 mctest_assert_str_eq (actual_hint2, "");
96 mctest_assert_str_eq (actual_hint3, "");
97
98 g_free (actual_hint3);
99 g_free (actual_hint2);
100 g_free (actual_hint1);
101 g_free (first_hint_for_ignore);
102 }
103
104 END_TEST
105
106
107
108 #define MC_HINT_FILE_SIZE 58
109
110
111 static const struct get_random_ds
112 {
113 int input_random_value;
114
115 const char *expected_value;
116 } get_random_ds[] =
117 {
118 {
119 MC_HINT_FILE_SIZE + 2,
120 "Para_1",
121 },
122 {
123 MC_HINT_FILE_SIZE + 10,
124 "Para_2_line_1 Para_2_line_2",
125 },
126 {
127 MC_HINT_FILE_SIZE + 25,
128 "Para_2_line_1 Para_2_line_2",
129 },
130 {
131 MC_HINT_FILE_SIZE + 40,
132 "Para_3",
133 },
134 {
135 MC_HINT_FILE_SIZE + 50,
136 "P A R A _ 4 ",
137 },
138 };
139
140
141
142 START_PARAMETRIZED_TEST (get_random, get_random_ds)
143
144 {
145
146 char *actual_value;
147
148 rand__return_value = data->input_random_value;
149
150
151 actual_value = get_random_hint (TRUE);
152
153
154 mctest_assert_str_eq (actual_value, data->expected_value);
155 g_free (actual_value);
156 }
157
158 END_PARAMETRIZED_TEST
159
160
161
162
163 int
164 main (void)
165 {
166 TCase *tc_core;
167
168 tc_core = tcase_create ("Core");
169
170 tcase_add_checked_fixture (tc_core, setup, teardown);
171
172
173 tcase_add_test (tc_core, test_not_force);
174 mctest_add_parameterized_test (tc_core, get_random, get_random_ds);
175
176
177 return mctest_run_all (tc_core);
178 }
179
180