torture:charset: test more of strcasecmp_m
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 5 Apr 2024 01:46:48 +0000 (14:46 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Apr 2024 22:56:33 +0000 (22:56 +0000)
We now test cases:

1. where the first string compares less
2. one of the strings ends before the other
3. the strings differ on a character other than the first.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/tests/charset.c

index 6fca3f36c19c0ec7729967dfe639fb78a5a2ecb3..bca5449c579f688c6556971a964f5aa7e4ee9d48 100644 (file)
@@ -73,11 +73,14 @@ 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_greater(tctx, strcasecmp_m("foo", "bar"), 0, "different strings both lower");
+       torture_assert_int_less(tctx, strcasecmp_m("bar", "foo"), 0, "different strings both lower");
        torture_assert_int_greater(tctx, strcasecmp_m("foo", "Bar"), 0, "different strings lower/upper");
        torture_assert_int_greater(tctx, strcasecmp_m("Foo", "bar"), 0, "different strings upper/lower");
        torture_assert_int_greater(tctx, strcasecmp_m("AFoo", "_bar"), 0, "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_greater(tctx, strcasecmp_m("food", "Foo"), 0, "strings differ towards the end");
+       torture_assert_int_less(tctx, strcasecmp_m("food", "Fool"), 0, "strings differ towards the end");
        torture_assert_int_less(tctx, strcasecmp_m(NULL, "Foo"),  0, "one NULL");
        torture_assert_int_greater(tctx, strcasecmp_m("foo", NULL),  0, "other NULL");
        torture_assert_int_equal(tctx, strcasecmp_m(NULL, NULL),   0, "both NULL");