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