basic/strv: add STRPTR_IN_SET
Also some trivial tests for STR_IN_SET and STRPTR_IN_SET.
This commit is contained in:
@@ -54,6 +54,25 @@ static void test_specifier_printf(void) {
|
||||
puts(w);
|
||||
}
|
||||
|
||||
static void test_str_in_set(void) {
|
||||
assert_se(STR_IN_SET("x", "x", "y", "z"));
|
||||
assert_se(!STR_IN_SET("X", "x", "y", "z"));
|
||||
assert_se(!STR_IN_SET("", "x", "y", "z"));
|
||||
assert_se(STR_IN_SET("x", "w", "x"));
|
||||
}
|
||||
|
||||
static void test_strptr_in_set(void) {
|
||||
assert_se(STRPTR_IN_SET("x", "x", "y", "z"));
|
||||
assert_se(!STRPTR_IN_SET("X", "x", "y", "z"));
|
||||
assert_se(!STRPTR_IN_SET("", "x", "y", "z"));
|
||||
assert_se(STRPTR_IN_SET("x", "w", "x"));
|
||||
|
||||
assert_se(!STRPTR_IN_SET(NULL, "x", "y", "z"));
|
||||
assert_se(!STRPTR_IN_SET(NULL, ""));
|
||||
/* strv cannot contain a null, hence the result below */
|
||||
assert_se(!STRPTR_IN_SET(NULL, NULL));
|
||||
}
|
||||
|
||||
static const char* const input_table_multiple[] = {
|
||||
"one",
|
||||
"two",
|
||||
@@ -703,6 +722,8 @@ static void test_strv_fnmatch(void) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
test_specifier_printf();
|
||||
test_str_in_set();
|
||||
test_strptr_in_set();
|
||||
test_strv_foreach();
|
||||
test_strv_foreach_backwards();
|
||||
test_strv_foreach_pair();
|
||||
|
||||
Reference in New Issue
Block a user