This source file includes following definitions.
- 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 #define TEST_SUITE_NAME "lib/search/glob"
27
28 #include "tests/mctest.h"
29
30 #include "glob.c"
31
32
33
34
35
36 static const struct test_glob_prepare_replace_str_ds
37 {
38 const char *input_value;
39 const char *glob_str;
40 const char *replace_str;
41 const char *expected_result;
42 } test_glob_prepare_replace_str_ds[] =
43 {
44 {
45 "qqwwee",
46 "*ww*",
47 "\\1AA\\2",
48 "qqAAee"
49 },
50 {
51 "qqwwee",
52 "*qq*",
53 "\\1SS\\2",
54 "SSwwee"
55 },
56 {
57 "qqwwee",
58 "*ee*",
59 "\\1RR\\2",
60 "qqwwRR"
61 }
62 };
63
64
65
66
67 START_PARAMETRIZED_TEST (test_glob_prepare_replace_str, test_glob_prepare_replace_str_ds)
68
69 {
70
71 mc_search_t *s;
72 char *dest_str;
73
74 s = mc_search_new (data->glob_str, NULL);
75 s->is_case_sensitive = TRUE;
76 s->search_type = MC_SEARCH_T_GLOB;
77
78
79 mc_search_run (s, data->input_value, 0, strlen (data->input_value), NULL);
80 dest_str = mc_search_prepare_replace_str2 (s, data->replace_str);
81
82
83 mctest_assert_str_eq (dest_str, data->expected_result);
84
85 g_free (dest_str);
86 mc_search_free (s);
87 }
88
89 END_PARAMETRIZED_TEST
90
91
92
93
94 int
95 main (void)
96 {
97 TCase *tc_core;
98
99 tc_core = tcase_create ("Core");
100
101
102 mctest_add_parameterized_test (tc_core, test_glob_prepare_replace_str,
103 test_glob_prepare_replace_str_ds);
104
105
106 return mctest_run_all (tc_core);
107 }
108
109