diff options
Diffstat (limited to 'libcutils/str_parms.c')
-rw-r--r-- | libcutils/str_parms.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/libcutils/str_parms.c b/libcutils/str_parms.c index dfe8c4ba7..924289aa9 100644 --- a/libcutils/str_parms.c +++ b/libcutils/str_parms.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011-2013 The Android Open Source Project | 2 | * Copyright (C) 2011 The Android Open Source Project |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
@@ -357,51 +357,3 @@ void str_parms_dump(struct str_parms *str_parms) | |||
357 | { | 357 | { |
358 | hashmapForEach(str_parms->map, dump_entry, str_parms); | 358 | hashmapForEach(str_parms->map, dump_entry, str_parms); |
359 | } | 359 | } |
360 | |||
361 | #ifdef TEST_STR_PARMS | ||
362 | static void test_str_parms_str(const char *str) | ||
363 | { | ||
364 | struct str_parms *str_parms; | ||
365 | char *out_str; | ||
366 | |||
367 | str_parms = str_parms_create_str(str); | ||
368 | str_parms_add_str(str_parms, "dude", "woah"); | ||
369 | str_parms_add_str(str_parms, "dude", "woah"); | ||
370 | str_parms_del(str_parms, "dude"); | ||
371 | str_parms_dump(str_parms); | ||
372 | out_str = str_parms_to_str(str_parms); | ||
373 | str_parms_destroy(str_parms); | ||
374 | ALOGI("%s: '%s' stringified is '%s'", __func__, str, out_str); | ||
375 | free(out_str); | ||
376 | } | ||
377 | |||
378 | int main(void) | ||
379 | { | ||
380 | test_str_parms_str(""); | ||
381 | test_str_parms_str(";"); | ||
382 | test_str_parms_str("="); | ||
383 | test_str_parms_str("=;"); | ||
384 | test_str_parms_str("=bar"); | ||
385 | test_str_parms_str("=bar;"); | ||
386 | test_str_parms_str("foo="); | ||
387 | test_str_parms_str("foo=;"); | ||
388 | test_str_parms_str("foo=bar"); | ||
389 | test_str_parms_str("foo=bar;"); | ||
390 | test_str_parms_str("foo=bar;baz"); | ||
391 | test_str_parms_str("foo=bar;baz="); | ||
392 | test_str_parms_str("foo=bar;baz=bat"); | ||
393 | test_str_parms_str("foo=bar;baz=bat;"); | ||
394 | test_str_parms_str("foo=bar;baz=bat;foo=bar"); | ||
395 | |||
396 | // hashmapPut reports errors by setting errno to ENOMEM. | ||
397 | // Test that we're not confused by running in an environment where this is already true. | ||
398 | errno = ENOMEM; | ||
399 | test_str_parms_str("foo=bar;baz="); | ||
400 | if (errno != ENOMEM) { | ||
401 | abort(); | ||
402 | } | ||
403 | test_str_parms_str("foo=bar;baz="); | ||
404 | |||
405 | return 0; | ||
406 | } | ||
407 | #endif | ||