diff options
author | Ronny Chevalier <chevalier.ronny@gmail.com> | 2014-12-11 18:30:16 +0100 |
---|---|---|
committer | Ronny Chevalier <chevalier.ronny@gmail.com> | 2014-12-11 18:32:57 +0100 |
commit | e74aa253e977ffd768a6d3af3535ea5b31e350a7 (patch) | |
tree | 1734b2a0ccdd4196bfdba9c1a5704a0ed9b3cee3 | |
parent | 27c5347c8c38bafedb1b48a5d8587d13eadcb90b (diff) |
test-strv: add test for strv_equal
-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 674c1b53fc..e09b4fb782 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -470,6 +470,27 @@ static void test_strv_push(void) { assert_se(streq_ptr(a[3], NULL)); } +static void test_strv_equal(void) { + _cleanup_strv_free_ char **a = NULL; + _cleanup_strv_free_ char **b = NULL; + _cleanup_strv_free_ char **c = NULL; + + a = strv_new("one", "two", "three", NULL); + assert_se(a); + b = strv_new("one", "two", "three", NULL); + assert_se(a); + c = strv_new("one", "two", "three", "four", NULL); + assert_se(a); + + assert_se(strv_equal(a, a)); + assert_se(strv_equal(a, b)); + assert_se(strv_equal(NULL, NULL)); + + assert_se(!strv_equal(a, c)); + assert_se(!strv_equal(b, c)); + assert_se(!strv_equal(b, NULL)); +} + int main(int argc, char *argv[]) { test_specifier_printf(); test_strv_foreach(); @@ -519,6 +540,7 @@ int main(int argc, char *argv[]) { test_strv_from_stdarg_alloca(); test_strv_push_prepend(); test_strv_push(); + test_strv_equal(); return 0; } |