]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: test-strfuncs - Add tests for literal versions of str_begins_with()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 10 Apr 2020 16:53:02 +0000 (19:53 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 23 Mar 2022 10:25:06 +0000 (10:25 +0000)
src/lib/test-strfuncs.c

index e112b203ae03339dd9325894eca0d26921925897..f48a53538d9db5ae99d6c31ba5a3317df82f53e5 100644 (file)
@@ -492,6 +492,14 @@ test_str_match(void)
                test_assert_idx(str_begins(tests[i].s1, tests[i].s2) ==
                                (strlen(tests[i].s2) == tests[i].match), i);
        }
+       /* test literal-optimized versions of these */
+       test_assert(str_begins_with("", ""));
+       test_assert(str_begins_with("123", ""));
+       test_assert(str_begins_with("123", "1"));
+       test_assert(str_begins_with("123", "123"));
+       test_assert(!str_begins_with("123", "1234"));
+       test_assert(!str_begins_with("", "123"));
+       test_assert(!str_begins_with("12", "123"));
        test_end();
 }