diff options
author | Lennart Poettering <lennart@poettering.net> | 2025-01-20 10:31:09 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2025-01-21 09:56:53 +0100 |
commit | 5072f4268b89a71e47e59c434da0222f722c7f0e (patch) | |
tree | 4c0c0d92594812b9d6b8d35d533e598f6cd30004 /src/test/test-strv.c | |
parent | networkd-test.py: generate debugging logs of networkd (diff) | |
download | systemd-5072f4268b89a71e47e59c434da0222f722c7f0e.tar.xz systemd-5072f4268b89a71e47e59c434da0222f722c7f0e.zip |
strv: add strv_equal_ignore_order() helper
Diffstat (limited to '')
-rw-r--r-- | src/test/test-strv.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c index d641043c50..b1d30d73a5 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -1255,4 +1255,26 @@ TEST(strv_find_closest) { ASSERT_NULL(strv_find_closest(l, "sfajosajfosdjaofjdsaf")); } +TEST(strv_equal_ignore_order) { + + ASSERT_TRUE(strv_equal_ignore_order(NULL, NULL)); + ASSERT_TRUE(strv_equal_ignore_order(NULL, STRV_MAKE(NULL))); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE(NULL), NULL)); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE(NULL), STRV_MAKE(NULL))); + + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE("foo"), NULL)); + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE("foo"), STRV_MAKE(NULL))); + ASSERT_FALSE(strv_equal_ignore_order(NULL, STRV_MAKE("foo"))); + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE(NULL), STRV_MAKE("foo"))); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE("foo"), STRV_MAKE("foo"))); + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE("foo"), STRV_MAKE("foo", "bar"))); + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE("foo", "bar"), STRV_MAKE("foo"))); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE("foo", "bar"), STRV_MAKE("foo", "bar"))); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE("bar", "foo"), STRV_MAKE("foo", "bar"))); + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE("bar", "foo"), STRV_MAKE("foo", "bar", "quux"))); + ASSERT_FALSE(strv_equal_ignore_order(STRV_MAKE("bar", "foo", "quux"), STRV_MAKE("foo", "bar"))); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE("bar", "foo", "quux"), STRV_MAKE("quux", "foo", "bar"))); + ASSERT_TRUE(strv_equal_ignore_order(STRV_MAKE("bar", "foo"), STRV_MAKE("bar", "foo", "bar", "foo", "foo"))); +} + DEFINE_TEST_MAIN(LOG_INFO); |