From 8e9691d97f6e58b322629eb4551eb98aa1b3e07d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 20 Oct 2009 07:59:14 +0200 Subject: [PATCH] test: added "run_hscroll" program A program for debugging the hscroll.c library. --- .gitignore | 2 ++ Makefile.am | 11 +++++++++++ test/run_hscroll.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/run_hscroll.c diff --git a/.gitignore b/.gitignore index ed05974..06f8483 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ stamp-* src/ncmpc src/ncmpc-tiny build + +test/run_hscroll diff --git a/Makefile.am b/Makefile.am index 966253b..1033e66 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 0000000..6bc4407 --- /dev/null +++ b/test/run_hscroll.c @@ -0,0 +1,42 @@ +#include "hscroll.h" +#include "config.h" + +#include +#include + +#ifdef ENABLE_LOCALE +#include +#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; +} -- 2.30.2