From: Timo Sirainen Date: Fri, 10 Apr 2020 16:53:02 +0000 (+0300) Subject: lib: test-strfuncs - Add tests for literal versions of str_begins_with() X-Git-Tag: 2.4.0~4239 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf408fc62e99b5b1298a2405593c28488f14c3a3;p=thirdparty%2Fdovecot%2Fcore.git lib: test-strfuncs - Add tests for literal versions of str_begins_with() --- diff --git a/src/lib/test-strfuncs.c b/src/lib/test-strfuncs.c index e112b203ae..f48a53538d 100644 --- a/src/lib/test-strfuncs.c +++ b/src/lib/test-strfuncs.c @@ -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(); }