1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

test-string-util: add another test for stripping slashes

I wrote this for my own "strip_trailing_chars" function, which was in the
meanwhile obsoleted by "delete_trailing_chars". Let's just keep the test.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-11-01 16:59:30 +01:00
parent c67f84b025
commit ca4d708dc4

View File

@ -320,6 +320,19 @@ static void test_delete_trailing_chars(void) {
assert_se(s == input3);
}
static void test_delete_trailing_slashes(void) {
char s1[] = "foobar//",
s2[] = "foobar/",
s3[] = "foobar",
s4[] = "";
assert_se(streq(delete_trailing_chars(s1, "_"), "foobar//"));
assert_se(streq(delete_trailing_chars(s1, "/"), "foobar"));
assert_se(streq(delete_trailing_chars(s2, "/"), "foobar"));
assert_se(streq(delete_trailing_chars(s3, "/"), "foobar"));
assert_se(streq(delete_trailing_chars(s4, "/"), ""));
}
static void test_skip_leading_chars(void) {
char input1[] = " \n \r k \n \r ",
input2[] = "kkkkthiskkkiskkkaktestkkk",
@ -399,6 +412,7 @@ int main(int argc, char *argv[]) {
test_endswith_no_case();
test_delete_chars();
test_delete_trailing_chars();
test_delete_trailing_slashes();
test_skip_leading_chars();
test_in_charset();
test_split_pair();