summaryrefslogtreecommitdiffstats
path: root/tests/ctrl/ctrl_test.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-12-16 01:03:37 +0100
committerHarald Welte <laforge@gnumonks.org>2017-12-18 23:05:49 +0000
commit0ab6eca80a47706375c5d54d829c4dee6e1228fc (patch)
treeb6e288b7cb059924e8623f2c49bb0ca2f15d138a /tests/ctrl/ctrl_test.c
parent9910bbc62d1c19a2cd75eeb1248c351b6a1e3f06 (diff)
ctrl_test.c: replace print_escaped() with new osmo_escape_str()
Change-Id: I12d3828dcc925f97fde11c360f1d60f3bd8cad8b
Diffstat (limited to 'tests/ctrl/ctrl_test.c')
-rw-r--r--tests/ctrl/ctrl_test.c40
1 files changed, 4 insertions, 36 deletions
diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index b8425c7e..2bc31285 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -37,45 +37,15 @@ struct msgb *msgb_from_string(const char *str)
static void *ctx = NULL;
-void print_escaped(const char *str)
-{
- if (!str) {
- printf("NULL");
- return;
- }
-
- printf("'");
- for (;*str; str++) {
- switch (*str) {
- case '\n':
- printf("\\n");
- break;
- case '\r':
- printf("\\r");
- break;
- case '\t':
- printf("\\t");
- break;
- default:
- printf("%c", *str);
- break;
- }
- }
- printf("'");
-}
-
void assert_same_str(const char *label, const char *expect, const char *got)
{
if ((expect == got) || (expect && got && (strcmp(expect, got) == 0))) {
- printf("%s = ", label);
- print_escaped(got);
- printf("\n");
+ printf("%s = '%s'\n", label, osmo_escape_str(got, -1));
return;
}
- printf("MISMATCH for '%s':\ngot: ", label); print_escaped(got);
- printf("\nexpected: "); print_escaped(expect);
- printf("\n");
+ printf("MISMATCH for '%s':\ngot: %s\n", label, osmo_escape_str(got, -1));
+ printf("expected: %s\n", osmo_escape_str(expect, -1));
OSMO_ASSERT(expect == got);
}
@@ -84,9 +54,7 @@ static void assert_parsing(const char *str, const struct ctrl_cmd *expect)
struct ctrl_cmd *cmd;
struct msgb *msg = msgb_from_string(str);
- printf("test parsing: ");
- print_escaped(str);
- printf("\n");
+ printf("test parsing: '%s'\n", osmo_escape_str(str, -1));
cmd = ctrl_cmd_parse(ctx, msg);
OSMO_ASSERT(cmd);