test: Replace assert_msg(strcmp(),...) with str_eq

str_eq will print the strings in case of failure:

Assertion '"BB." == buf' failed: "BB." == "BB.", buf == "BA."
This commit is contained in:
Erik Ekman 2021-08-24 23:07:36 +02:00
parent 5388eae1df
commit f09dadb1ed
4 changed files with 7 additions and 14 deletions

View file

@ -49,8 +49,7 @@ START_TEST(test_base32_encode)
val = base32_ops.encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a)); val = base32_ops.encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a));
ck_assert(val == strlen(testpairs[_i].b)); ck_assert(val == strlen(testpairs[_i].b));
ck_assert_msg(strcmp(buf, testpairs[_i].b) == 0, ck_assert_str_eq(buf, testpairs[_i].b);
"'%s' != '%s'", buf, testpairs[_i].b);
} }
END_TEST END_TEST
@ -64,8 +63,7 @@ START_TEST(test_base32_decode)
val = base32_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b)); val = base32_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
ck_assert(val == strlen(testpairs[_i].a)); ck_assert(val == strlen(testpairs[_i].a));
ck_assert_msg(strcmp(buf, testpairs[_i].a) == 0, ck_assert_str_eq(buf, testpairs[_i].a);
"'%s' != '%s'", buf, testpairs[_i].a);
} }
END_TEST END_TEST

View file

@ -74,8 +74,7 @@ START_TEST(test_base64_encode)
val = base64_ops.encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a)); val = base64_ops.encode(buf, &len, testpairs[_i].a, strlen(testpairs[_i].a));
ck_assert(val == strlen(testpairs[_i].b)); ck_assert(val == strlen(testpairs[_i].b));
ck_assert_msg(strcmp(buf, testpairs[_i].b) == 0, ck_assert_str_eq(buf, testpairs[_i].b);
"'%s' != '%s'", buf, testpairs[_i].b);
} }
END_TEST END_TEST
@ -89,8 +88,7 @@ START_TEST(test_base64_decode)
val = base64_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b)); val = base64_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
ck_assert(val == strlen(testpairs[_i].a)); ck_assert(val == strlen(testpairs[_i].a));
ck_assert_msg(strcmp(buf, testpairs[_i].a) == 0, ck_assert_str_eq(buf, testpairs[_i].a);
"'%s' != '%s'", buf, testpairs[_i].a);
} }
END_TEST END_TEST

View file

@ -50,8 +50,7 @@ START_TEST(test_inline_dotify)
b = temp; b = temp;
inline_dotify(b, sizeof(temp)); inline_dotify(b, sizeof(temp));
ck_assert_msg(strcmp(dottests[_i].b, temp) == 0, ck_assert_str_eq(dottests[_i].b, temp);
"'%s' != '%s'", temp, dottests[_i].b);
} }
END_TEST END_TEST
@ -65,8 +64,7 @@ START_TEST(test_inline_undotify)
b = temp; b = temp;
inline_undotify(b, sizeof(temp)); inline_undotify(b, sizeof(temp));
ck_assert_msg(strcmp(dottests[_i].a, temp) == 0, ck_assert_str_eq(dottests[_i].a, temp);
"'%s' != '%s'", temp, dottests[_i].a);
} }
END_TEST END_TEST

View file

@ -205,8 +205,7 @@ START_TEST(test_read_name_badjump_second)
rv = readname((char*) jumper, sizeof(badjump2), &data, buf, 256); rv = readname((char*) jumper, sizeof(badjump2), &data, buf, 256);
ck_assert(rv == 4); ck_assert(rv == 4);
ck_assert_msg(strcmp("BA.", buf) == 0, ck_assert_str_eq("BA.", buf);
"buf is not BA: %s", buf);
} }
free(jumper); free(jumper);
} }