diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 10 | ||||
-rw-r--r-- | test/helper-test.c | 31 |
2 files changed, 40 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index ca005fe3..94893669 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,7 +1,7 @@ ## # Rofi the program ## -bin_PROGRAMS=rofi_test textbox_test +bin_PROGRAMS=rofi_test textbox_test helper_test LIBS=\ @xft_LIBS@\ @@ -33,9 +33,17 @@ textbox_test_SOURCES=\ ../include/textbox.h\ textbox-test.c +helper_test_SOURCES=\ + helper-test.c\ + ../config/config.c\ + ../include/rofi.h\ + ../source/helper.c\ + ../include/helper.h + .PHONY: test test: ${bin_PROGRAMS} ./rofi_test + ./helper_test $(top_srcdir)/test/run_test.sh 123 $(top_builddir)/test/textbox_test $(top_builddir) $(top_srcdir)/test/run_test.sh 200 $(top_srcdir)/test/run_errormsg_test.sh $(top_builddir) $(top_srcdir)/test/run_test.sh 201 $(top_srcdir)/test/run_switchdialog_test.sh $(top_builddir) diff --git a/test/helper-test.c b/test/helper-test.c new file mode 100644 index 00000000..2d64372a --- /dev/null +++ b/test/helper-test.c @@ -0,0 +1,31 @@ +#include <assert.h> +#include <glib.h> +#include <stdio.h> +#include <helper.h> +#include <string.h> + +static int test = 0; + +#define TASSERT(a) {\ + assert ( a );\ + printf("Test %i passed (%s)\n", ++test, #a);\ +} + +int main ( int argc, char ** argv ) +{ + char **list = NULL; + int llength = 0; + char * test_str = "{host} {terminal} -e bash -c \"{ssh-client} {host}; echo '{terminal} {host}'\""; + helper_parse_setup( test_str, &list, &llength, "{host}", "chuck", + "{terminal}", "x-terminal-emulator", NULL); + + TASSERT ( llength == 6 ); + TASSERT ( strcmp(list[0], "chuck") == 0 ); + TASSERT ( strcmp(list[1], "x-terminal-emulator") == 0 ); + TASSERT ( strcmp(list[2], "-e") == 0 ); + TASSERT ( strcmp(list[3], "bash") == 0 ); + TASSERT ( strcmp(list[4], "-c") == 0 ); + TASSERT ( strcmp(list[5], "ssh chuck; echo 'x-terminal-emulator chuck'") == 0 ); + + g_strfreev(list); +} |