Changeset 740 for vendor/current/lib/util/tests
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/lib/util/tests
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/util/tests/data_blob.c
r414 r740 79 79 { 80 80 DATA_BLOB a = data_blob_string_const("\xC\xA\xF\xE"); 81 torture_assert_str_equal(tctx, data_blob_hex_string(tctx, &a), "0C0A0F0E", "hex string"); 81 torture_assert_str_equal(tctx, data_blob_hex_string_lower(tctx, &a), "0c0a0f0e", "hex string"); 82 torture_assert_str_equal(tctx, data_blob_hex_string_upper(tctx, &a), "0C0A0F0E", "hex string"); 82 83 return true; 83 84 } … … 85 86 struct torture_suite *torture_local_util_data_blob(TALLOC_CTX *mem_ctx) 86 87 { 87 struct torture_suite *suite = torture_suite_create(mem_ctx, " DATABLOB");88 struct torture_suite *suite = torture_suite_create(mem_ctx, "datablob"); 88 89 89 90 torture_suite_add_simple_test(suite, "string", test_string); -
vendor/current/lib/util/tests/file.c
r414 r740 92 92 struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx) 93 93 { 94 struct torture_suite *suite = torture_suite_create(mem_ctx, " FILE");94 struct torture_suite *suite = torture_suite_create(mem_ctx, "file"); 95 95 96 96 torture_suite_add_simple_test(suite, "file_load_save", 97 97 test_file_load_save); 98 98 99 torture_suite_add_simple_test(suite, "afdgets", 100 test_afdgets); 99 torture_suite_add_simple_test(suite, "afdgets", test_afdgets); 101 100 102 101 return suite; -
vendor/current/lib/util/tests/genrand.c
r414 r740 60 60 struct torture_suite *torture_local_genrand(TALLOC_CTX *mem_ctx) 61 61 { 62 struct torture_suite *suite = torture_suite_create(mem_ctx, " GENRAND");62 struct torture_suite *suite = torture_suite_create(mem_ctx, "genrand"); 63 63 torture_suite_add_simple_test(suite, "reseed_callback", test_reseed_callback); 64 64 torture_suite_add_simple_test(suite, "check_password_quality", test_check_password_quality); -
vendor/current/lib/util/tests/idtree.c
r414 r740 116 116 struct torture_suite *torture_local_idtree(TALLOC_CTX *mem_ctx) 117 117 { 118 struct torture_suite *suite = torture_suite_create(mem_ctx, " IDTREE");118 struct torture_suite *suite = torture_suite_create(mem_ctx, "idtree"); 119 119 torture_suite_add_simple_test(suite, "idtree", torture_local_idtree_simple); 120 120 return suite; -
vendor/current/lib/util/tests/parmlist.c
r414 r740 60 60 torture_assert_str_equal(tctx, e->value, "mystring", "value"); 61 61 62 e = parmlist_get(pctx, "non existant");63 torture_assert(tctx, e == NULL, "non existant");62 e = parmlist_get(pctx, "non-existent"); 63 torture_assert(tctx, e == NULL, "non-existent"); 64 64 return true; 65 65 } … … 88 88 torture_assert_str_equal(tctx, "true", ret[0], "ret[0]"); 89 89 torture_assert_str_equal(tctx, "false", ret[1], "ret[1]"); 90 torture_assert(tctx, NULL == parmlist_get_string_list(pctx, "non existant", NULL), "nonexistant");90 torture_assert(tctx, NULL == parmlist_get_string_list(pctx, "non-existent", NULL), "non-existent"); 91 91 92 92 return true; … … 95 95 struct torture_suite *torture_local_util_parmlist(TALLOC_CTX *mem_ctx) 96 96 { 97 struct torture_suite *suite = torture_suite_create(mem_ctx, " PARMLIST");97 struct torture_suite *suite = torture_suite_create(mem_ctx, "parmlist"); 98 98 99 99 torture_suite_add_simple_test(suite, "get_int", test_get_int); -
vendor/current/lib/util/tests/str.c
r414 r740 95 95 struct torture_suite *torture_local_util_str(TALLOC_CTX *mem_ctx) 96 96 { 97 struct torture_suite *suite = torture_suite_create(mem_ctx, " STR");97 struct torture_suite *suite = torture_suite_create(mem_ctx, "str"); 98 98 99 99 torture_suite_add_simple_test(suite, "string_sub_simple", -
vendor/current/lib/util/tests/strlist.c
r414 r740 27 27 struct test_list_element { 28 28 const char *list_as_string; 29 const char *sep erators;29 const char *separators; 30 30 const char *list[5]; 31 31 }; 32 32 33 struct test_list_element test_lists_strings[] = {33 const struct test_list_element test_lists_strings[] = { 34 34 { 35 35 .list_as_string = "", … … 47 47 .list_as_string = "foo bar", 48 48 .list = { "foo bar", NULL }, 49 .sep erators = ";"49 .separators = ";" 50 50 }, 51 51 { … … 60 60 .list_as_string = "\"foo bar\",comma;semicolon", 61 61 .list = { "\"foo bar\",comma", "semicolon", NULL }, 62 .sep erators = ";"62 .separators = ";" 63 63 } 64 64 }; 65 65 66 struct test_list_element test_lists_shell_strings[] = {66 const struct test_list_element test_lists_shell_strings[] = { 67 67 { 68 68 .list_as_string = "", … … 80 80 .list_as_string = "foo bar", 81 81 .list = { "foo bar", NULL }, 82 .sep erators = ";"82 .separators = ";" 83 83 }, 84 84 { … … 100 100 }; 101 101 102 static bool test_lists_shell(struct torture_context *tctx, 103 const void *data) 102 static bool test_lists_shell(struct torture_context *tctx, const void *data) 104 103 { 105 104 const struct test_list_element *element = data; 106 const char **ret1, **ret2, *tmp; 105 106 char **ret1, **ret2, *tmp; 107 107 bool match = true; 108 108 TALLOC_CTX *mem_ctx = tctx; 109 109 110 ret1 = str_list_make_shell(mem_ctx, element->list_as_string, element->sep erators);110 ret1 = str_list_make_shell(mem_ctx, element->list_as_string, element->separators); 111 111 112 112 torture_assert(tctx, ret1, "str_list_make_shell() must not return NULL"); 113 tmp = str_list_join_shell(mem_ctx, ret1, element->seperators ? *element->seperators : ' ');114 ret2 = str_list_make_shell(mem_ctx, tmp, element->sep erators);113 tmp = str_list_join_shell(mem_ctx, (const char **) ret1, element->separators ? *element->separators : ' '); 114 ret2 = str_list_make_shell(mem_ctx, tmp, element->separators); 115 115 116 116 if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) { … … 131 131 torture_assert(tctx, match, talloc_asprintf(tctx, 132 132 "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", element->list_as_string, tmp)); 133 torture_assert(tctx, str_list_equal(ret1, element->list), 133 torture_assert(tctx, str_list_equal((const char * const *) ret1, 134 element->list), 134 135 talloc_asprintf(tctx, 135 136 "str_list_make_shell(%s) failed to create correct list", … … 142 143 { 143 144 const struct test_list_element *element = data; 145 144 146 char **result; 145 result = str_list_make(tctx, element->list_as_string, element->sep erators);147 result = str_list_make(tctx, element->list_as_string, element->separators); 146 148 torture_assert(tctx, result, "str_list_make() must not return NULL"); 147 torture_assert(tctx, str_list_equal((const char **)result, element->list), 149 torture_assert(tctx, str_list_equal((const char * const *) result, 150 element->list), 148 151 talloc_asprintf(tctx, 149 152 "str_list_make(%s) failed to create correct list", … … 251 254 static bool test_list_add(struct torture_context *tctx) 252 255 { 253 c har **result, **result2;256 const char **result, **result2; 254 257 const char *list[] = { 255 258 "element_0", … … 259 262 NULL 260 263 }; 261 result = str_list_make(tctx, "element_0, element_1, element_2", NULL);264 result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL); 262 265 torture_assert(tctx, result, "str_list_make() must not return NULL"); 263 result2 = str_list_add( result, "element_3");266 result2 = str_list_add((const char **) result, "element_3"); 264 267 torture_assert(tctx, result2, "str_list_add() must not return NULL"); 265 268 torture_assert(tctx, str_list_equal(result2, list), … … 271 274 static bool test_list_add_const(struct torture_context *tctx) 272 275 { 273 c har **result, **result2;276 const char **result, **result2; 274 277 const char *list[] = { 275 278 "element_0", … … 279 282 NULL 280 283 }; 281 result = str_list_make(tctx, "element_0, element_1, element_2", NULL);284 result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL); 282 285 torture_assert(tctx, result, "str_list_make() must not return NULL"); 283 286 result2 = str_list_add_const(result, "element_3"); … … 291 294 static bool test_list_remove(struct torture_context *tctx) 292 295 { 293 c har **result;296 const char **result; 294 297 const char *list[] = { 295 298 "element_0", … … 298 301 NULL 299 302 }; 300 result = str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);303 result = (const char **) str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL); 301 304 torture_assert(tctx, result, "str_list_make() must not return NULL"); 302 305 str_list_remove(result, "element_2"); … … 337 340 static bool test_list_unique(struct torture_context *tctx) 338 341 { 339 c har **result;342 const char **result; 340 343 const char *list[] = { 341 344 "element_0", … … 355 358 NULL 356 359 }; 357 result = str_list_copy(tctx, list_dup);360 result = (const char **) str_list_copy(tctx, list_dup); 358 361 /* We must copy the list, as str_list_unique does a talloc_realloc() on it's parameter */ 359 362 result = str_list_unique(result); … … 374 377 const char **list_dup = (const char **)str_list_make_empty(tctx); 375 378 376 count = lp _parm_int(tctx->lp_ctx, NULL, "list_unique", "count", 9);377 num_dups = lp _parm_int(tctx->lp_ctx, NULL, "list_unique", "dups", 7);379 count = lpcfg_parm_int(tctx->lp_ctx, NULL, "list_unique", "count", 9); 380 num_dups = lpcfg_parm_int(tctx->lp_ctx, NULL, "list_unique", "dups", 7); 378 381 torture_comment(tctx, "test_list_unique_2() with %d elements and %d dups\n", count, num_dups); 379 382 … … 399 402 static bool test_list_append(struct torture_context *tctx) 400 403 { 401 c har **result;404 const char **result; 402 405 const char *list[] = { 403 406 "element_0", … … 421 424 NULL 422 425 }; 423 result = str_list_copy(tctx, list);426 result = (const char **) str_list_copy(tctx, list); 424 427 torture_assert(tctx, result, "str_list_copy() must not return NULL"); 425 428 result = str_list_append(result, list2); … … 433 436 static bool test_list_append_const(struct torture_context *tctx) 434 437 { 435 c har **result;438 const char **result; 436 439 const char *list[] = { 437 440 "element_0", … … 455 458 NULL 456 459 }; 457 result = str_list_copy(tctx, list);460 result = (const char **) str_list_copy(tctx, list); 458 461 torture_assert(tctx, result, "str_list_copy() must not return NULL"); 459 462 result = str_list_append_const(result, list2); … … 467 470 struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) 468 471 { 469 struct torture_suite *suite = torture_suite_create(mem_ctx, " STRLIST");472 struct torture_suite *suite = torture_suite_create(mem_ctx, "strlist"); 470 473 int i; 471 474 472 475 for (i = 0; i < ARRAY_SIZE(test_lists_shell_strings); i++) { 473 torture_suite_add_simple_tcase_const(suite, "lists_shell", 474 test_lists_shell, &test_lists_shell_strings[i]); 476 char *name; 477 name = talloc_asprintf(suite, "lists_shell(%s)", 478 test_lists_shell_strings[i].list_as_string); 479 torture_suite_add_simple_tcase_const(suite, name, 480 test_lists_shell, &test_lists_shell_strings[i]); 475 481 } 476 482 477 483 for (i = 0; i < ARRAY_SIZE(test_lists_strings); i++) { 478 torture_suite_add_simple_tcase_const(suite, "lists", 479 test_list_make, &test_lists_strings[i]); 484 char *name; 485 name = talloc_asprintf(suite, "list_make(%s)", 486 test_lists_strings[i].list_as_string); 487 torture_suite_add_simple_tcase_const(suite, name, 488 test_list_make, &test_lists_strings[i]); 480 489 } 481 490 -
vendor/current/lib/util/tests/time.c
r414 r740 78 78 79 79 result = timestring(tctx, 42 - (utc_offset < 0 ? utc_offset : 0)); 80 torture_assert(tctx, !strncmp(start, result, strlen(start)), 81 result); 80 torture_assert(tctx, !strncmp(start, result, strlen(start)), result); 82 81 return true; 83 82 } … … 102 101 struct torture_suite *torture_local_util_time(TALLOC_CTX *mem_ctx) 103 102 { 104 struct torture_suite *suite = torture_suite_create(mem_ctx, " TIME");103 struct torture_suite *suite = torture_suite_create(mem_ctx, "time"); 105 104 106 105 torture_suite_add_simple_test(suite, "null_time", test_null_time);
Note:
See TracChangeset
for help on using the changeset viewer.