summaryrefslogtreecommitdiff
path: root/src/test/test-strv.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-01-15 13:59:11 +0100
committerGitHub <noreply@github.com>2020-01-15 13:59:11 +0100
commit98f44b97bb49673b32a3bc824067950c23321840 (patch)
treed4a0b1dc247156fa35387730bca9055535d14797 /src/test/test-strv.c
parenta50414fce54d824785eea075b1fc9e5c50da4730 (diff)
parentbbaba5748d6539900990ad97236b8251e8fc797a (diff)
downloadsystemd-98f44b97bb49673b32a3bc824067950c23321840.tar.gz
Merge pull request #14562 from yuwata/table-strv
introduce TABLE_STRV and use it in networkctl and resolvectl
Diffstat (limited to 'src/test/test-strv.c')
-rw-r--r--src/test/test-strv.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index b63cb4b63e..dd6233175c 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -711,27 +711,33 @@ static void test_strv_push(void) {
assert_se(streq_ptr(a[3], NULL));
}
-static void test_strv_equal(void) {
+static void test_strv_compare(void) {
_cleanup_strv_free_ char **a = NULL;
_cleanup_strv_free_ char **b = NULL;
_cleanup_strv_free_ char **c = NULL;
+ _cleanup_strv_free_ char **d = NULL;
log_info("/* %s */", __func__);
a = strv_new("one", "two", "three");
assert_se(a);
b = strv_new("one", "two", "three");
- assert_se(a);
+ assert_se(b);
c = strv_new("one", "two", "three", "four");
- assert_se(a);
+ assert_se(c);
+ d = strv_new(NULL);
+ assert_se(d);
- assert_se(strv_equal(a, a));
- assert_se(strv_equal(a, b));
- assert_se(strv_equal(NULL, NULL));
+ assert_se(strv_compare(a, a) == 0);
+ assert_se(strv_compare(a, b) == 0);
+ assert_se(strv_compare(d, d) == 0);
+ assert_se(strv_compare(d, NULL) == 0);
+ assert_se(strv_compare(NULL, NULL) == 0);
- assert_se(!strv_equal(a, c));
- assert_se(!strv_equal(b, c));
- assert_se(!strv_equal(b, NULL));
+ assert_se(strv_compare(a, c) < 0);
+ assert_se(strv_compare(b, c) < 0);
+ assert_se(strv_compare(b, d) == 1);
+ assert_se(strv_compare(b, NULL) == 1);
}
static void test_strv_is_uniq(void) {
@@ -990,7 +996,7 @@ int main(int argc, char *argv[]) {
test_strv_insert();
test_strv_push_prepend();
test_strv_push();
- test_strv_equal();
+ test_strv_compare();
test_strv_is_uniq();
test_strv_reverse();
test_strv_shell_escape();