23
23
24
24
void test_replace_whitespaces (void * * state )
25
25
{
26
- TALLOC_CTX * mem_ctx ;
27
- const char * input_str = "Lorem ipsum dolor sit amet" ;
28
- const char * res ;
29
26
size_t i ;
27
+ char * input ;
30
28
31
29
struct {
32
30
const char * input ;
@@ -51,36 +49,18 @@ void test_replace_whitespaces(void **state)
51
49
{ NULL , NULL , '\0' },
52
50
};
53
51
54
- mem_ctx = talloc_new (NULL );
55
- assert_non_null (mem_ctx );
56
- check_leaks_push (mem_ctx );
57
-
58
- res = sss_replace_space (mem_ctx , input_str , '\0' );
59
- assert_string_equal (res , input_str );
60
- talloc_zfree (res );
61
-
62
- res = sss_replace_space (mem_ctx , input_str , '\0' );
63
- assert_string_equal (res , input_str );
64
- talloc_zfree (res );
65
-
66
52
for (i = 0 ; data_set [i ].input != NULL ; ++ i ) {
67
- res = sss_replace_space (mem_ctx , data_set [i ].input ,
68
- data_set [i ].replace_char );
69
- assert_non_null (res );
70
- assert_string_equal (res , data_set [i ].output );
71
- talloc_zfree (res );
53
+ input = strdup (data_set [i ].input );
54
+ sss_replace_space_inplace (input , data_set [i ].replace_char );
55
+ assert_string_equal (input , data_set [i ].output );
56
+ free (input );
72
57
}
73
-
74
- assert_true (check_leaks_pop (mem_ctx ) == true);
75
- talloc_free (mem_ctx );
76
58
}
77
59
78
60
void test_reverse_replace_whitespaces (void * * state )
79
61
{
80
- TALLOC_CTX * mem_ctx ;
81
- char * input_str = discard_const_p (char , "Lorem ipsum dolor sit amet" );
82
- char * res ;
83
62
size_t i ;
63
+ char * input ;
84
64
85
65
struct {
86
66
const char * input ;
@@ -109,29 +89,12 @@ void test_reverse_replace_whitespaces(void **state)
109
89
{ NULL , NULL , '\0' },
110
90
};
111
91
112
- mem_ctx = talloc_new (NULL );
113
- assert_non_null (mem_ctx );
114
- check_leaks_push (mem_ctx );
115
-
116
- res = sss_reverse_replace_space (mem_ctx , input_str , '\0' );
117
- assert_string_equal (res , input_str );
118
- talloc_free (res );
119
-
120
- res = sss_reverse_replace_space (mem_ctx , input_str , '\0' );
121
- assert_string_equal (res , input_str );
122
- talloc_free (res );
123
-
124
92
for (i = 0 ; data_set [i ].input != NULL ; ++ i ) {
125
- input_str = discard_const_p (char , data_set [i ].input );
126
- res = sss_reverse_replace_space (mem_ctx , input_str ,
127
- data_set [i ].replace_char );
128
- assert_non_null (res );
129
- assert_string_equal (res , data_set [i ].output );
130
- talloc_zfree (res );
93
+ input = strdup (data_set [i ].input );
94
+ sss_reverse_replace_space_inplace (input , data_set [i ].replace_char );
95
+ assert_string_equal (input , data_set [i ].output );
96
+ free (input );
131
97
}
132
-
133
- assert_true (check_leaks_pop (mem_ctx ) == true);
134
- talloc_free (mem_ctx );
135
98
}
136
99
137
100
void test_guid_blob_to_string_buf (void * * state )
0 commit comments