mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
tests: enhance str-test with a negative test on str_replace_str
This commit is contained in:
@@ -54,10 +54,18 @@ int main()
|
||||
STR_TAB_SET(5, "%U", "u1");
|
||||
STR_TAB_TERM(6);
|
||||
|
||||
/* check proper operation */
|
||||
#define STR2 "This is one route1, and one route2, while a route3 was replaced by dev1 and dev2 and dev1. That's all u1."
|
||||
str_reset(&str);
|
||||
str_append_str(&str, "This is one %R, and one %{R}, while a %{R2} was replaced by %{D} and %D and %{D}. That's all %U.");
|
||||
str_replace_str(&str, tab);
|
||||
if (str_append_str(&str, "This is one %R, and one %{R}, while a %{R2} was replaced by %{D} and %D and %{D}. That's all %U.") != 0) {
|
||||
fprintf(stderr, "error in %d\n", __LINE__);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (str_replace_str(&str, tab) != 0) {
|
||||
fprintf(stderr, "error in %d\n", __LINE__);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (str.length != sizeof(STR2)-1) {
|
||||
fprintf(stderr, "error in %d\n", __LINE__);
|
||||
@@ -69,5 +77,13 @@ int main()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* check failure on unknown pattern */
|
||||
str_reset(&str);
|
||||
str_append_str(&str, "This is one %A.");
|
||||
if (str_replace_str(&str, tab) == 0) {
|
||||
fprintf(stderr, "error in %d\n", __LINE__);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user