summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Buch <boogiewasthere@gmail.com>2013-01-30 21:45:40 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-30 23:37:39 -0500
commit682cfdff697707dbe29c9c1907a7c8c452ffb397 (patch)
tree14826a17b65166935b201cf31039681b4ee38620 /src
parent3a7719d303c14a74040944485e3e366db3f9fcc5 (diff)
test-strv.c: test strv_join added
Diffstat (limited to 'src')
-rw-r--r--src/test/test-strv.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 44b067cec4..7898ea7cf6 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -23,6 +23,7 @@
#include "util.h"
#include "specifier.h"
+#include "strv.h"
static void test_specifier_printf(void) {
char *w;
@@ -52,6 +53,49 @@ static void test_foreach_word_quoted(void) {
}
}
+static void test_strv_join(void) {
+ char *r;
+
+ const char * const input_table_multiple[] = {
+ "one",
+ "two",
+ "three",
+ NULL
+ };
+ const char * const input_table_one[] = {
+ "one",
+ NULL
+ };
+ const char * const input_table_none[] = {
+ NULL
+ };
+
+ r = strv_join((char **)input_table_multiple, ", ");
+ assert_se(streq(r, "one, two, three"));
+ puts(r);
+ free(r);
+
+ r = strv_join((char **)input_table_multiple, ";");
+ assert_se(streq(r, "one;two;three"));
+ puts(r);
+ free(r);
+
+ r = strv_join((char **)input_table_multiple, NULL);
+ assert_se(streq(r, "one two three"));
+ puts(r);
+ free(r);
+
+ r = strv_join((char **)input_table_one, ", ");
+ assert_se(streq(r, "one"));
+ puts(r);
+ free(r);
+
+ r = strv_join((char **)input_table_none, ", ");
+ assert_se(streq(r, ""));
+ puts(r);
+ free(r);
+}
+
static void test_default_term_for_tty(void) {
printf("%s\n", default_term_for_tty("/dev/tty23"));
printf("%s\n", default_term_for_tty("/dev/ttyS23"));
@@ -71,6 +115,7 @@ int main(int argc, char *argv[]) {
test_default_term_for_tty();
test_foreach_word_quoted();
test_specifier_printf();
+ test_strv_join();
return 0;
}