summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2017-09-06 10:39:00 +0200
committerStefan Metzmacher <metze@samba.org>2017-09-16 09:24:12 +0200
commitc6a49313f696b9f893bba2b03ad66f4322fb7be7 (patch)
treea1f81fe893f4deb6ad5463abcb9b50818a84c873 /lib/util
parent7e472300399603b8e6db333884a3530f5bc0ce72 (diff)
downloadsamba-c6a49313f696b9f893bba2b03ad66f4322fb7be7.tar.gz
charset/tests: add more str[n]casecmp_m() tests to demonstrate the bug
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> (cherry picked from commit 2a3d4fe0c9eacf9d0b2261ef116a1f6b741e20ee)
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/charset/tests/charset.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/util/charset/tests/charset.c b/lib/util/charset/tests/charset.c
index e2d4155a4b8..918bf57fb99 100644
--- a/lib/util/charset/tests/charset.c
+++ b/lib/util/charset/tests/charset.c
@@ -55,6 +55,9 @@ static bool test_strcasecmp_m(struct torture_context *tctx)
/* file.{accented e} in utf8 */
const char file_utf8[8] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
torture_assert_int_equal(tctx, strcasecmp_m("foo", "bar"), 4, "different strings both lower");
+ torture_assert_int_equal(tctx, strcasecmp_m("foo", "Bar"), 4, "different strings lower/upper");
+ torture_assert_int_equal(tctx, strcasecmp_m("Foo", "bar"), 4, "different strings upper/lower");
+ torture_assert_int_equal(tctx, strcasecmp_m("AFoo", "_bar"), 2, "different strings upper/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");
@@ -112,7 +115,10 @@ 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_int_equal(tctx, strncasecmp_m("foo", "bar", 3), 4, "different strings");
+ torture_assert_int_equal(tctx, strncasecmp_m("foo", "bar", 3), 4, "different strings both lower");
+ torture_assert_int_equal(tctx, strncasecmp_m("foo", "Bar", 3), 4, "different strings lower/upper");
+ torture_assert_int_equal(tctx, strncasecmp_m("Foo", "bar", 3), 4, "different strings upper/lower");
+ torture_assert_int_equal(tctx, strncasecmp_m("AFoo", "_bar", 4), 2, "different strings upper/lower");
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");