This source file includes following definitions.
- setup
- teardown
- START_TEST
- START_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 "/lib/strutil"
24
25 #include "tests/mctest.h"
26
27 #include "lib/strutil.h"
28
29
30
31
32 static void
33 setup (void)
34 {
35 }
36
37
38
39
40 static void
41 teardown (void)
42 {
43 }
44
45
46
47
48
49 static const struct str_rstrip_eol_test_struct
50 {
51 const char *input_string;
52 const char *expected_result;
53 } str_rstrip_eol_test_ds1[] = {
54 {
55 "",
56 "",
57 },
58 {
59 " \n\r",
60 " \n",
61 },
62 {
63 " \t\r\n",
64 " \t",
65 },
66 {
67 "a \r ",
68 "a \r ",
69 },
70 {
71 " a \n ",
72 " a \n ",
73 },
74 {
75 "a a\n\r\n",
76 "a a\n",
77 },
78 {
79 "\na a \r",
80 "\na a ",
81 },
82 };
83
84
85 START_TEST (str_rstrip_eol_test1)
86 {
87
88 const struct str_rstrip_eol_test_struct *data = &str_rstrip_eol_test_ds1[_i];
89
90
91 char *actual_result = g_strdup (data->input_string);
92 str_rstrip_eol (actual_result);
93
94
95 ck_assert_str_eq (actual_result, data->expected_result);
96
97 g_free (actual_result);
98 }
99
100 END_TEST
101
102 START_TEST (str_rstrip_eol_test_null)
103 {
104 char *ptr = NULL;
105 str_rstrip_eol (ptr);
106 ck_assert_ptr_null (ptr);
107 }
108
109 END_TEST
110
111 int
112 main (void)
113 {
114 TCase *tc_core;
115
116 tc_core = tcase_create ("Core");
117
118 tcase_add_checked_fixture (tc_core, setup, teardown);
119
120
121 mctest_add_parameterized_test (tc_core, str_rstrip_eol_test1, str_rstrip_eol_test_ds1);
122 tcase_add_test (tc_core, str_rstrip_eol_test_null);
123
124
125 return mctest_run_all (tc_core);
126 }
127
128