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