mirror of
https://github.com/MariaDB/server.git
synced 2025-07-21 23:50:01 +00:00
unittest output improvement for json_normalize-t
The ok() function outputs the TAP context string in both the success and failure cases. The strings were worded to make sense in the failure case, yet were confusing in the success case. This changes the strings to be appropriate, and even more informative in either the success or failure cases. In the cases where input, expected, and result values are included in the context string, they have been adjusted such that expected and actual result values are aligned for easy visual comparison. Signed-off-by: Eric Herman <eric@freesa.org>
This commit is contained in:

committed by
Daniel Black

parent
f5821aaf77
commit
7734c85c31
@ -32,11 +32,11 @@ check_json_normalize(const char *in, const char *expected)
|
||||
|
||||
err= json_normalize(&result, in, strlen(in), cs);
|
||||
|
||||
ok(err == 0, "normalize err?");
|
||||
ok(err == 0, "normalize err: %d", err);
|
||||
|
||||
ok(strcmp(expected, result.str) == 0,
|
||||
"expected '%s' from '%s' but was '%s'",
|
||||
expected, in, result.str);
|
||||
"from '%s'\n expect: '%s'\n actual: '%s'",
|
||||
in, expected, result.str);
|
||||
|
||||
dynstr_free(&result);
|
||||
}
|
||||
@ -205,13 +205,13 @@ test_json_normalize_non_utf8(void)
|
||||
|
||||
init_dynamic_string(&result, NULL, 0, 0);
|
||||
err= json_normalize(&result, utf8, strlen(utf8), cs_utf8);
|
||||
ok(err == 0, "normalize err?");
|
||||
ok(err == 0, "normalize err: %d", err);
|
||||
ok((strcmp(utf8, result.str) == 0), "utf8 round trip");
|
||||
dynstr_free(&result);
|
||||
|
||||
init_dynamic_string(&result, NULL, 0, 0);
|
||||
err= json_normalize(&result, latin, strlen(latin), cs_latin);
|
||||
ok(err == 0, "normalize err?");
|
||||
ok(err == 0, "normalize err: %d", err);
|
||||
ok((strcmp(utf8, result.str) == 0), "latin to utf8 round trip");
|
||||
dynstr_free(&result);
|
||||
}
|
||||
@ -226,15 +226,15 @@ check_number_normalize(const char *in, const char *expected)
|
||||
init_dynamic_string(&buf, NULL, 0, 0);
|
||||
|
||||
err= json_normalize_number(&buf, in, strlen(in));
|
||||
ok(err == 0, "normalize number err?");
|
||||
ok(err == 0, "normalize number err: %d", err);
|
||||
|
||||
ok(strcmp(buf.str, expected) == 0,
|
||||
" from: %s\n"
|
||||
"expected: %s\n"
|
||||
" but was: %s\n"
|
||||
" from: %s\n",
|
||||
" actual: %s\n",
|
||||
in,
|
||||
expected,
|
||||
buf.str,
|
||||
in);
|
||||
buf.str);
|
||||
|
||||
dynstr_free(&buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user