summaryrefslogtreecommitdiff
path: root/lib/util/charset
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2017-09-06 10:38:37 +0200
committerRalph Boehme <slow@samba.org>2017-09-14 22:30:20 +0200
commitc18ecdececef8fcfdaa5d3e1a066533c8b41f19d (patch)
treedabdeda2ab5acae29d3be918ca14773a7a82268b /lib/util/charset
parent3f0938b9389dc9c0ca5e4acf0451f14050a7506f (diff)
downloadsamba-c18ecdececef8fcfdaa5d3e1a066533c8b41f19d.tar.gz
charset/tests: assert the exact values of str[n]casecmp_m()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13018 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'lib/util/charset')
-rw-r--r--lib/util/charset/tests/charset.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/util/charset/tests/charset.c b/lib/util/charset/tests/charset.c
index 7f3365623ca..e2d4155a4b8 100644
--- a/lib/util/charset/tests/charset.c
+++ b/lib/util/charset/tests/charset.c
@@ -54,13 +54,13 @@ static bool test_strcasecmp_m(struct torture_context *tctx)
const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
/* file.{accented e} in utf8 */
const char file_utf8[8] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
- torture_assert(tctx, strcasecmp_m("foo", "bar") != 0, "different strings");
- torture_assert(tctx, strcasecmp_m("foo", "foo") == 0, "same case strings");
- torture_assert(tctx, strcasecmp_m("foo", "Foo") == 0, "different case strings");
- torture_assert(tctx, strcasecmp_m(NULL, "Foo") != 0, "one NULL");
- torture_assert(tctx, strcasecmp_m("foo", NULL) != 0, "other NULL");
- torture_assert(tctx, strcasecmp_m(NULL, NULL) == 0, "both NULL");
- torture_assert(tctx, strcasecmp_m(file_iso8859_1, file_utf8) != 0,
+ torture_assert_int_equal(tctx, strcasecmp_m("foo", "bar"), 4, "different strings both lower");
+ torture_assert_int_equal(tctx, strcasecmp_m("foo", "foo"), 0, "same case strings");
+ torture_assert_int_equal(tctx, strcasecmp_m("foo", "Foo"), 0, "different case strings");
+ torture_assert_int_equal(tctx, strcasecmp_m(NULL, "Foo"), -1, "one NULL");
+ torture_assert_int_equal(tctx, strcasecmp_m("foo", NULL), 1, "other NULL");
+ torture_assert_int_equal(tctx, strcasecmp_m(NULL, NULL), 0, "both NULL");
+ torture_assert_int_equal(tctx, strcasecmp_m(file_iso8859_1, file_utf8), 38,
"file.{accented e} should differ");
return true;
}
@@ -112,16 +112,16 @@ static bool test_strncasecmp_m(struct torture_context *tctx)
const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
/* file.{accented e} in utf8 */
const char file_utf8[8] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
- torture_assert(tctx, strncasecmp_m("foo", "bar", 3) != 0, "different strings");
- torture_assert(tctx, strncasecmp_m("foo", "foo", 3) == 0, "same case strings");
- torture_assert(tctx, strncasecmp_m("foo", "Foo", 3) == 0, "different case strings");
- torture_assert(tctx, strncasecmp_m("fool", "Foo", 3) == 0, "different case strings");
- torture_assert(tctx, strncasecmp_m("fool", "Fool", 40) == 0, "over size");
- torture_assert(tctx, strncasecmp_m("BLA", "Fool", 0) == 0, "empty");
- torture_assert(tctx, strncasecmp_m(NULL, "Foo", 3) != 0, "one NULL");
- torture_assert(tctx, strncasecmp_m("foo", NULL, 3) != 0, "other NULL");
- torture_assert(tctx, strncasecmp_m(NULL, NULL, 3) == 0, "both NULL");
- torture_assert(tctx, strncasecmp_m(file_iso8859_1, file_utf8, 6) != 0,
+ torture_assert_int_equal(tctx, strncasecmp_m("foo", "bar", 3), 4, "different strings");
+ torture_assert_int_equal(tctx, strncasecmp_m("foo", "foo", 3), 0, "same case strings");
+ torture_assert_int_equal(tctx, strncasecmp_m("foo", "Foo", 3), 0, "different case strings");
+ torture_assert_int_equal(tctx, strncasecmp_m("fool", "Foo", 3),0, "different case strings");
+ torture_assert_int_equal(tctx, strncasecmp_m("fool", "Fool", 40), 0, "over size");
+ torture_assert_int_equal(tctx, strncasecmp_m("BLA", "Fool", 0),0, "empty");
+ torture_assert_int_equal(tctx, strncasecmp_m(NULL, "Foo", 3), -1, "one NULL");
+ torture_assert_int_equal(tctx, strncasecmp_m("foo", NULL, 3), 1, "other NULL");
+ torture_assert_int_equal(tctx, strncasecmp_m(NULL, NULL, 3), 0, "both NULL");
+ torture_assert_int_equal(tctx, strncasecmp_m(file_iso8859_1, file_utf8, 6), 38,
"file.{accented e} should differ");
return true;
}