summaryrefslogtreecommitdiff
path: root/src/test/test-strv.c
diff options
context:
space:
mode:
authorDaniel Buch <boogiewasthere@gmail.com>2013-10-27 12:45:53 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-27 11:51:22 -0400
commit02f19706a9fd96e05c9ed16aa55ba3d03d008167 (patch)
tree26a5ad1032260e4c54e64db95ae0ce8fcc5f8c28 /src/test/test-strv.c
parentfb15be839500c39f6c2f006f45306d439e1a7add (diff)
test-strv.c: added STRV_FOREACH and STRV_FOREACH_BACKWARDS
Diffstat (limited to 'src/test/test-strv.c')
-rw-r--r--src/test/test-strv.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index c3d536d057..de5cef0b17 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -282,6 +282,34 @@ static void test_strv_append(void) {
assert_se(streq(c[0], "test3"));
}
+static void test_strv_foreach(void) {
+ _cleanup_strv_free_ char **a;
+ unsigned i = 0;
+ char **check;
+
+ a = strv_new("one", "two", "three", NULL);
+
+ assert_se(a);
+
+ STRV_FOREACH(check, a) {
+ assert_se(streq(*check, input_table_multiple[i++]));
+ }
+}
+
+static void test_strv_foreach_backwards(void) {
+ _cleanup_strv_free_ char **a;
+ unsigned i = 2;
+ char **check;
+
+ a = strv_new("one", "two", "three", NULL);
+
+ assert_se(a);
+
+ STRV_FOREACH_BACKWARDS(check, a) {
+ assert_se(streq(*check, input_table_multiple[i--]));
+ }
+}
+
static void test_strv_foreach_pair(void) {
_cleanup_strv_free_ char **a = NULL;
char **x, **y;
@@ -298,6 +326,8 @@ static void test_strv_foreach_pair(void) {
int main(int argc, char *argv[]) {
test_specifier_printf();
+ test_strv_foreach();
+ test_strv_foreach_backwards();
test_strv_foreach_pair();
test_strv_find();
test_strv_find_prefix();