This source file includes following definitions.
- setup
- teardown
- setup_charset
- teardown_charset
- 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 #define TEST_SUITE_NAME "/src/usermenu"
24
25 #include "tests/mctest.h"
26
27 #include "lib/charsets.h"
28
29 #include "src/usermenu.c"
30
31
32
33 static void
34 setup (void)
35 {
36 easy_patterns = FALSE;
37
38 current_panel = g_new0 (WPanel, 1);
39 current_panel->dir.size = 4;
40 current_panel->dir.len = current_panel->dir.size;
41 current_panel->dir.list = g_new0 (file_entry_t, current_panel->dir.size);
42
43 file_entry_t *list = current_panel->dir.list;
44
45 list[0].fname = g_string_new ("file_without_spaces");
46 list[1].fname = g_string_new ("file with spaces");
47 list[2].fname = g_string_new ("file_without_spaces_utf8_local_chars_ä_ü_ö_ß_");
48 list[3].fname = g_string_new ("file_without_spaces_utf8_nonlocal_chars_à_á_");
49 }
50
51
52
53 static void
54 teardown (void)
55 {
56 dir_list_free_list (¤t_panel->dir);
57 MC_PTR_FREE (current_panel);
58 }
59
60
61
62 static void
63 setup_charset (const char *encoding, const gboolean utf8_display)
64 {
65 str_init_strings (encoding);
66
67 mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
68 load_codepages_list ();
69
70 cp_source = encoding;
71 cp_display = encoding;
72 mc_global.source_codepage = get_codepage_index (encoding);
73 mc_global.display_codepage = get_codepage_index (encoding);
74
75 mc_global.utf8_display = utf8_display;
76 }
77
78
79
80 static void
81 teardown_charset (void)
82 {
83 free_codepages_list ();
84 str_uninit_strings ();
85 }
86
87
88
89 static const struct check_test_condition_ds
90 {
91 const char *encoding;
92 gboolean utf8_display;
93 int current_file;
94 gboolean expected_value;
95 } check_test_condition_ds[] = {
96
97 { "UTF-8", TRUE, 0, FALSE },
98 { "UTF-8", TRUE, 1, TRUE },
99 { "UTF-8", TRUE, 2, FALSE },
100 { "UTF-8", TRUE, 3, FALSE },
101
102
103
104 { "KOI8-R", FALSE, 0, FALSE },
105 { "KOI8-R", FALSE, 1, TRUE },
106 { "KOI8-R", FALSE, 2, FALSE },
107 { "KOI8-R", FALSE, 3, TRUE },
108 };
109
110
111
112 START_PARAMETRIZED_TEST (check_test_condition, check_test_condition_ds)
113 {
114 setup_charset (data->encoding, data->utf8_display);
115 char *condition = g_strdup ("f [[:space:]] & t r");
116
117 current_panel->current = data->current_file;
118
119 gboolean result = FALSE;
120 test_condition (NULL, condition, &result);
121 ck_assert_int_eq (result, data->expected_value);
122
123 g_free (condition);
124 teardown_charset ();
125 }
126 END_PARAMETRIZED_TEST
127
128
129
130 int
131 main (void)
132 {
133 TCase *tc_core;
134
135 tc_core = tcase_create ("Core");
136
137 tcase_add_checked_fixture (tc_core, setup, teardown);
138
139
140 mctest_add_parameterized_test (tc_core, check_test_condition, check_test_condition_ds);
141
142
143 return mctest_run_all (tc_core);
144 }
145
146