Code

test: added "run_hscroll" program
authorMax Kellermann <max@duempel.org>
Tue, 20 Oct 2009 05:59:14 +0000 (07:59 +0200)
committerMax Kellermann <max@duempel.org>
Tue, 20 Oct 2009 05:59:14 +0000 (07:59 +0200)
A program for debugging the hscroll.c library.

.gitignore
Makefile.am
test/run_hscroll.c [new file with mode: 0644]

index ed05974206d44bec91aa6b05c4baf10fb586d7d5..06f848333ca402314ee7bf7bc2dd59b239d97458 100644 (file)
@@ -22,3 +22,5 @@ stamp-*
 src/ncmpc
 src/ncmpc-tiny
 build
+
+test/run_hscroll
index 966253bff457c1d28901fb274c9c8cdab3a8396e..1033e66b3ab05a2fd7b27e1d93d01128dfb7bf21 100644 (file)
@@ -158,6 +158,17 @@ src/ncmpc-tiny: $(filter-out %.h,$(src_ncmpc_SOURCES))
 
 CLEANFILES = src/ncmpc-tiny
 
+#
+# test suite
+#
+
+check_PROGRAMS = \
+       test/run_hscroll
+
+test_run_hscroll_SOURCES = test/run_hscroll.c src/hscroll.c src/charset.c
+test_run_hscroll_CPPFLAGS = -Isrc $(AM_CPPFLAGS)
+test_run_hscroll_LDFLAGS = $(GLIB_LIBS)
+
 #
 # sparse
 #
diff --git a/test/run_hscroll.c b/test/run_hscroll.c
new file mode 100644 (file)
index 0000000..6bc4407
--- /dev/null
@@ -0,0 +1,42 @@
+#include "hscroll.h"
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+
+#ifdef ENABLE_LOCALE
+#include <locale.h>
+#endif
+
+int main(int argc, char **argv)
+{
+       struct hscroll hscroll;
+       char *p;
+       unsigned width, count;
+
+       if (argc != 5) {
+               g_printerr("Usage: %s TEXT SEPARATOR WIDTH COUNT\n", argv[0]);
+               return 1;
+       }
+
+#ifdef ENABLE_LOCALE
+       setlocale(LC_CTYPE,"");
+#endif
+
+       hscroll_reset(&hscroll);
+
+       width = atoi(argv[3]);
+       count = atoi(argv[4]);
+
+       for (unsigned i = 0; i < count; ++i) {
+               p = strscroll(&hscroll, argv[1], argv[2], width);
+               g_print("%s\n", p);
+               g_free(p);
+
+               hscroll_step(&hscroll);
+       }
+
+       hscroll_reset(&hscroll);
+
+       return 0;
+}