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));
ck_assert(val == strlen(testpairs[_i].b));
ck_assert_msg(strcmp(buf, testpairs[_i].b) == 0,
"'%s' != '%s'", buf, testpairs[_i].b);
ck_assert_str_eq(buf, testpairs[_i].b);
}
END_TEST
@ -64,8 +63,7 @@ START_TEST(test_base32_decode)
val = base32_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
ck_assert(val == strlen(testpairs[_i].a));
ck_assert_msg(strcmp(buf, testpairs[_i].a) == 0,
"'%s' != '%s'", buf, testpairs[_i].a);
ck_assert_str_eq(buf, testpairs[_i].a);
}
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));
ck_assert(val == strlen(testpairs[_i].b));
ck_assert_msg(strcmp(buf, testpairs[_i].b) == 0,
"'%s' != '%s'", buf, testpairs[_i].b);
ck_assert_str_eq(buf, testpairs[_i].b);
}
END_TEST
@ -89,8 +88,7 @@ START_TEST(test_base64_decode)
val = base64_ops.decode(buf, &len, testpairs[_i].b, strlen(testpairs[_i].b));
ck_assert(val == strlen(testpairs[_i].a));
ck_assert_msg(strcmp(buf, testpairs[_i].a) == 0,
"'%s' != '%s'", buf, testpairs[_i].a);
ck_assert_str_eq(buf, testpairs[_i].a);
}
END_TEST

View File

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

View File

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