aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_ast_format_str_reduce.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-09 23:32:14 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-09 23:32:14 +0000
commitd8d63de32861045cd40b3036fac3077e7af90ed3 (patch)
treed10f5c6801b7a0d86ccd2dd6b5b3986e93b82fb5 /tests/test_ast_format_str_reduce.c
parent687dfce0fd28482651b03df103c6e630a3dc4317 (diff)
Various updates to the unit test API.
1) It occurred to me that the difference in usage between the error ast_str and the ast_test_update_status() usage has turned out to be a bit ambiguous in practice. In a lot of cases, the same message was being sent to both. In other cases, it was only sent to one or the other. My opinion now is that in every case, I think it makes sense to do both; we should output it to the CLI as well as save it off for logging purposes. This change results in most of the changes in this diff, since it required changes to all existing unit tests. It also allowed for some simplifications of unit test API implementation code. 2) Update ast_test_status_update() to include the file, function, and line number for the code providing the update. 3) There are some formatting tweaks here and there. Hopefully they aren't too distracting for code review purposes. Reviewboard's diff viewer seems to do a pretty good job of pointing out when something is a whitespace change. 4) I moved the md5_test and sha1_test into the test_utils module. It seemed like a better approach since these tests are so tiny. 5) I changed the number of nodes used in heap_test_2 from 1 million to 100 thousand. The only reason for this was to reduce the time it took for this test to run. 6) Remove an unused function prototype that was at the bottom of utils.h. 7) Simplify test_insert() using the LIST_INSERT_SORTALPHA() macro. The one minor difference in behavior is that it no longer checks for a test registered with the same name. 8) Expand the code in test_alloc() to provide specific error messages for each failure case, to clearly inform developers if they forget to set the name, summary, description, etc. 9) Tweak the output of the "test show registered" CLI command. I swapped the name and category to have the category first. It seemed more natural since that is the sort key. 10) Don't output the status ast_str in the "test show results" CLI command. This is going to tend to be pretty verbose, so just leave that for the detailed test logs (test generate results). Review: https://reviewboard.asterisk.org/r/493/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@245864 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'tests/test_ast_format_str_reduce.c')
-rw-r--r--tests/test_ast_format_str_reduce.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/test_ast_format_str_reduce.c b/tests/test_ast_format_str_reduce.c
index 0c24ab2d1..8dd1f500f 100644
--- a/tests/test_ast_format_str_reduce.c
+++ b/tests/test_ast_format_str_reduce.c
@@ -94,12 +94,14 @@ AST_TEST_DEFINE(ast_format_str_reduce_test_1)
for (i = 0; test_strings[i][0]; i++) {
c = ast_strdupa(test_strings[i][0]);
if (!(c = ast_format_str_reduce(c))) {
- ast_str_set(&args->ast_test_error_str, 0, "Error running ast_format_str_reduce() on string '%s'\n", test_strings[i][0]);
+ ast_test_status_update(test, "Error running ast_format_str_reduce() on string '%s'\n",
+ test_strings[i][0]);
return AST_TEST_FAIL;
}
if (strcmp(test_strings[i][1], c)) {
- ast_str_set(&args->ast_test_error_str, 0, "Format string '%s' reduced to '%s'. Expected '%s'\n", test_strings[i][0], c, test_strings[i][1]);
+ ast_test_status_update(test, "Format string '%s' reduced to '%s'. Expected '%s'\n",
+ test_strings[i][0], c, test_strings[i][1]);
return AST_TEST_FAIL;
}
}
@@ -107,7 +109,9 @@ AST_TEST_DEFINE(ast_format_str_reduce_test_1)
for (i = 0; fail_strings[i]; i++) {
c = ast_strdupa(fail_strings[i]);
if ((c = ast_format_str_reduce(c))) {
- ast_str_set(&args->ast_test_error_str, 0, "ast_format_str_reduce() succeded on string '%s' with result '%s', but we expected it to fail\n", fail_strings[i], c);
+ ast_test_status_update(test, "ast_format_str_reduce() succeded on string '%s' "
+ "with result '%s', but we expected it to fail\n",
+ fail_strings[i], c);
return AST_TEST_FAIL;
}
}