summaryrefslogtreecommitdiffstats
path: root/lib/tests/test_utils.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-26 07:05:21 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-26 07:05:21 (GMT)
commitba132e9e521218efc5d35aa5f7a024cba93f5e29 (patch)
tree9328162d51cc85d99cf7c18b40e3b9684a17dedf /lib/tests/test_utils.c
parent0a74b6fda08c484cba7216596d2ffa3931b900e5 (diff)
downloadmonitoring-plugins-ba132e9e521218efc5d35aa5f7a024cba93f5e29.tar.gz
Make extract_value more generic:
Add a separator argument passed using defines.
Diffstat (limited to 'lib/tests/test_utils.c')
-rw-r--r--lib/tests/test_utils.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index 97343af..3a45944 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -172,83 +172,83 @@ main (int argc, char **argv)
172 test = np_escaped_string("everything"); 172 test = np_escaped_string("everything");
173 ok( strcmp(test, "everything") == 0, "everything okay"); 173 ok( strcmp(test, "everything") == 0, "everything okay");
174 174
175 /* np_extract_value tests (23) */ 175 /* np_extract_ntpvar tests (23) */
176 test=np_extract_value("foo=bar, bar=foo, foobar=barfoo\n", "foo"); 176 test=np_extract_ntpvar("foo=bar, bar=foo, foobar=barfoo\n", "foo");
177 ok(test && !strcmp(test, "bar"), "1st test as expected"); 177 ok(test && !strcmp(test, "bar"), "1st test as expected");
178 free(test); 178 free(test);
179 179
180 test=np_extract_value("foo=bar,bar=foo,foobar=barfoo\n", "bar"); 180 test=np_extract_ntpvar("foo=bar,bar=foo,foobar=barfoo\n", "bar");
181 ok(test && !strcmp(test, "foo"), "2nd test as expected"); 181 ok(test && !strcmp(test, "foo"), "2nd test as expected");
182 free(test); 182 free(test);
183 183
184 test=np_extract_value("foo=bar, bar=foo, foobar=barfoo\n", "foobar"); 184 test=np_extract_ntpvar("foo=bar, bar=foo, foobar=barfoo\n", "foobar");
185 ok(test && !strcmp(test, "barfoo"), "3rd test as expected"); 185 ok(test && !strcmp(test, "barfoo"), "3rd test as expected");
186 free(test); 186 free(test);
187 187
188 test=np_extract_value("foo=bar\n", "foo"); 188 test=np_extract_ntpvar("foo=bar\n", "foo");
189 ok(test && !strcmp(test, "bar"), "Single test as expected"); 189 ok(test && !strcmp(test, "bar"), "Single test as expected");
190 free(test); 190 free(test);
191 191
192 test=np_extract_value("foo=bar, bar=foo, foobar=barfooi\n", "abcd"); 192 test=np_extract_ntpvar("foo=bar, bar=foo, foobar=barfooi\n", "abcd");
193 ok(!test, "Key not found 1"); 193 ok(!test, "Key not found 1");
194 194
195 test=np_extract_value("foo=bar\n", "abcd"); 195 test=np_extract_ntpvar("foo=bar\n", "abcd");
196 ok(!test, "Key not found 2"); 196 ok(!test, "Key not found 2");
197 197
198 test=np_extract_value("foo=bar=foobar", "foo"); 198 test=np_extract_ntpvar("foo=bar=foobar", "foo");
199 ok(test && !strcmp(test, "bar=foobar"), "Strange string 1"); 199 ok(test && !strcmp(test, "bar=foobar"), "Strange string 1");
200 free(test); 200 free(test);
201 201
202 test=np_extract_value("foo", "foo"); 202 test=np_extract_ntpvar("foo", "foo");
203 ok(!test, "Malformed string 1"); 203 ok(!test, "Malformed string 1");
204 204
205 test=np_extract_value("foo,", "foo"); 205 test=np_extract_ntpvar("foo,", "foo");
206 ok(!test, "Malformed string 2"); 206 ok(!test, "Malformed string 2");
207 207
208 test=np_extract_value("foo=", "foo"); 208 test=np_extract_ntpvar("foo=", "foo");
209 ok(!test, "Malformed string 3"); 209 ok(!test, "Malformed string 3");
210 210
211 test=np_extract_value("foo=,bar=foo", "foo"); 211 test=np_extract_ntpvar("foo=,bar=foo", "foo");
212 ok(!test, "Malformed string 4"); 212 ok(!test, "Malformed string 4");
213 213
214 test=np_extract_value(",foo", "foo"); 214 test=np_extract_ntpvar(",foo", "foo");
215 ok(!test, "Malformed string 5"); 215 ok(!test, "Malformed string 5");
216 216
217 test=np_extract_value("=foo", "foo"); 217 test=np_extract_ntpvar("=foo", "foo");
218 ok(!test, "Malformed string 6"); 218 ok(!test, "Malformed string 6");
219 219
220 test=np_extract_value("=foo,", "foo"); 220 test=np_extract_ntpvar("=foo,", "foo");
221 ok(!test, "Malformed string 7"); 221 ok(!test, "Malformed string 7");
222 222
223 test=np_extract_value(",,,", "foo"); 223 test=np_extract_ntpvar(",,,", "foo");
224 ok(!test, "Malformed string 8"); 224 ok(!test, "Malformed string 8");
225 225
226 test=np_extract_value("===", "foo"); 226 test=np_extract_ntpvar("===", "foo");
227 ok(!test, "Malformed string 9"); 227 ok(!test, "Malformed string 9");
228 228
229 test=np_extract_value(",=,=,", "foo"); 229 test=np_extract_ntpvar(",=,=,", "foo");
230 ok(!test, "Malformed string 10"); 230 ok(!test, "Malformed string 10");
231 231
232 test=np_extract_value("=,=,=", "foo"); 232 test=np_extract_ntpvar("=,=,=", "foo");
233 ok(!test, "Malformed string 11"); 233 ok(!test, "Malformed string 11");
234 234
235 test=np_extract_value(" foo=bar ,\n bar=foo\n , foobar=barfoo \n ", "foo"); 235 test=np_extract_ntpvar(" foo=bar ,\n bar=foo\n , foobar=barfoo \n ", "foo");
236 ok(test && !strcmp(test, "bar"), "Random spaces and newlines 1"); 236 ok(test && !strcmp(test, "bar"), "Random spaces and newlines 1");
237 free(test); 237 free(test);
238 238
239 test=np_extract_value(" foo=bar ,\n bar=foo\n , foobar=barfoo \n ", "bar"); 239 test=np_extract_ntpvar(" foo=bar ,\n bar=foo\n , foobar=barfoo \n ", "bar");
240 ok(test && !strcmp(test, "foo"), "Random spaces and newlines 2"); 240 ok(test && !strcmp(test, "foo"), "Random spaces and newlines 2");
241 free(test); 241 free(test);
242 242
243 test=np_extract_value(" foo=bar ,\n bar=foo\n , foobar=barfoo \n ", "foobar"); 243 test=np_extract_ntpvar(" foo=bar ,\n bar=foo\n , foobar=barfoo \n ", "foobar");
244 ok(test && !strcmp(test, "barfoo"), "Random spaces and newlines 3"); 244 ok(test && !strcmp(test, "barfoo"), "Random spaces and newlines 3");
245 free(test); 245 free(test);
246 246
247 test=np_extract_value(" foo=bar ,\n bar\n \n= \n foo\n , foobar=barfoo \n ", "bar"); 247 test=np_extract_ntpvar(" foo=bar ,\n bar\n \n= \n foo\n , foobar=barfoo \n ", "bar");
248 ok(test && !strcmp(test, "foo"), "Random spaces and newlines 4"); 248 ok(test && !strcmp(test, "foo"), "Random spaces and newlines 4");
249 free(test); 249 free(test);
250 250
251 test=np_extract_value("", "foo"); 251 test=np_extract_ntpvar("", "foo");
252 ok(!test, "Empty string return NULL"); 252 ok(!test, "Empty string return NULL");
253 253
254 return exit_status(); 254 return exit_status();