summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be0c6ac)
raw | patch | inline | side by side (parent: be0c6ac)
author | Max Kellermann <max@duempel.org> | |
Tue, 20 Oct 2009 05:59:14 +0000 (07:59 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 20 Oct 2009 05:59:14 +0000 (07:59 +0200) |
A program for debugging the hscroll.c library.
.gitignore | patch | blob | history | |
Makefile.am | patch | blob | history | |
test/run_hscroll.c | [new file with mode: 0644] | patch | blob |
diff --git a/.gitignore b/.gitignore
index ed05974206d44bec91aa6b05c4baf10fb586d7d5..06f848333ca402314ee7bf7bc2dd59b239d97458 100644 (file)
--- a/.gitignore
+++ b/.gitignore
src/ncmpc
src/ncmpc-tiny
build
+
+test/run_hscroll
diff --git a/Makefile.am b/Makefile.am
index 966253bff457c1d28901fb274c9c8cdab3a8396e..1033e66b3ab05a2fd7b27e1d93d01128dfb7bf21 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
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
--- /dev/null
+++ b/test/run_hscroll.c
@@ -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;
+}