X-Git-Url: http://git.silcnet.org/gitweb/?p=crypto.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Ftests%2Ftest_silcregex.c;h=87b7a5f40b2628e1ac0783f8efc55608d5c70774;hp=ba98bbe036ac87007523f9df0931658ad1987a59;hb=89429cd0dc7e29b8284d5b6066f94719509ec885;hpb=f2462c5dd7e885e3daa00066fbf53e166fd361e0 diff --git a/lib/silcutil/tests/test_silcregex.c b/lib/silcutil/tests/test_silcregex.c index ba98bbe0..87b7a5f4 100644 --- a/lib/silcutil/tests/test_silcregex.c +++ b/lib/silcutil/tests/test_silcregex.c @@ -24,7 +24,7 @@ int main(int argc, char **argv) string = "Hello World"; SILC_LOG_DEBUG(("Match %s", string)); - if (!silc_regex_match(®, string, num_match, match, 0)) + if (!silc_regex_match(®, string, strlen(string), num_match, match, 0)) goto err; for (i = 0; i < num_match; i++) { if (match[i].start != -1) { @@ -46,17 +46,17 @@ int main(int argc, char **argv) string = "foo"; SILC_LOG_DEBUG(("Match %s", string)); - if (!silc_regex_match(®, string, 0, NULL, 0)) + if (!silc_regex_match(®, string, strlen(string), 0, NULL, 0)) goto err; string = "foo20"; SILC_LOG_DEBUG(("Match %s", string)); - if (!silc_regex_match(®, string, 0, NULL, 0)) + if (!silc_regex_match(®, string, strlen(string), 0, NULL, 0)) goto err; string = "foo20, bar, foo100, foo"; SILC_LOG_DEBUG(("Match all substrings in %s", string)); - while (silc_regex_match(®, string, 1, match, 0)) { + while (silc_regex_match(®, string, strlen(string), 1, match, 0)) { SILC_LOG_DEBUG(("Match start %d", match[0].start)); sub = silc_memdup(string + match[0].start, match[0].end - match[0].start); SILC_LOG_DEBUG(("Match substring '%s'", sub)); @@ -66,7 +66,7 @@ int main(int argc, char **argv) string = "foo20, bar, foo100, Foo, foo0"; SILC_LOG_DEBUG(("Match all substrings at once in %s", string)); - if (!silc_regex_match(®, string, num_match, match, 0)) + if (!silc_regex_match(®, string, strlen(string), num_match, match, 0)) goto err; for (i = 0; i < num_match; i++) { @@ -88,7 +88,7 @@ int main(int argc, char **argv) string = "http://silcnet.org:443/foobar/pelle.html"; SILC_LOG_DEBUG(("Parse URI")); - if (!silc_regex_match(®, string, num_match, match, 0)) + if (!silc_regex_match(®, string, strlen(string), num_match, match, 0)) goto err; for (i = 0; i < num_match; i++) { @@ -103,7 +103,7 @@ int main(int argc, char **argv) string = "http://silcnet.org/"; SILC_LOG_DEBUG(("Parse URI")); - if (!silc_regex_match(®, string, num_match, match, 0)) + if (!silc_regex_match(®, string, strlen(string), num_match, match, 0)) goto err; for (i = 0; i < num_match; i++) { @@ -125,7 +125,7 @@ int main(int argc, char **argv) string = "ab"; SILC_LOG_DEBUG(("Match all substrings at once in %s", string)); - if (!silc_regex_match(®, string, num_match, match, 0)) + if (!silc_regex_match(®, string, strlen(string), num_match, match, 0)) goto err; for (i = 0; i < num_match; i++) { @@ -140,6 +140,38 @@ int main(int argc, char **argv) silc_regex_free(®); + regex = "^a"; + SILC_LOG_DEBUG(("Regex %s", regex)); + if (!silc_regex_compile(®, regex, 0)) + goto err; + + string = "a"; + SILC_LOG_DEBUG(("Test NOTBOL flag", string)); + if (silc_regex_match(®, string, strlen(string), 0, NULL, + SILC_REGEX_NOTBOL)) + goto err; + if (silc_errno != SILC_ERR_NOT_FOUND) + goto err; + SILC_LOG_DEBUG(("Did not match (OK)")); + + silc_regex_free(®); + + regex = "a$"; + SILC_LOG_DEBUG(("Regex %s", regex)); + if (!silc_regex_compile(®, regex, 0)) + goto err; + + string = "a"; + SILC_LOG_DEBUG(("Test NOTEOL flag", string)); + if (silc_regex_match(®, string, strlen(string), 0, NULL, + SILC_REGEX_NOTEOL)) + goto err; + if (silc_errno != SILC_ERR_NOT_FOUND) + goto err; + SILC_LOG_DEBUG(("Did not match (OK)")); + + silc_regex_free(®); + success = TRUE; err: