mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Split test for helper in separate test for config cmdline parser.
This commit is contained in:
parent
3ac0c6dd7d
commit
6693799923
3 changed files with 81 additions and 17 deletions
20
Makefile.am
20
Makefile.am
|
@ -139,7 +139,7 @@ update-manpage: $(top_srcdir)/doc/rofi-manpage.markdown
|
||||||
##
|
##
|
||||||
# Rofi test program
|
# Rofi test program
|
||||||
##
|
##
|
||||||
check_PROGRAMS=history_test textbox_test helper_test helper_expand
|
check_PROGRAMS=history_test textbox_test helper_test helper_expand helper_config_cmdline_parser
|
||||||
|
|
||||||
history_test_CFLAGS=\
|
history_test_CFLAGS=\
|
||||||
$(AM_CFLAGS)\
|
$(AM_CFLAGS)\
|
||||||
|
@ -251,10 +251,26 @@ helper_expand_CFLAGS=${helper_test_CFLAGS}
|
||||||
|
|
||||||
helper_expand_LDADD=${helper_test_LDADD}
|
helper_expand_LDADD=${helper_test_LDADD}
|
||||||
|
|
||||||
|
helper_config_cmdline_parser_CFLAGS=${helper_test_CFLAGS}
|
||||||
|
|
||||||
|
helper_config_cmdline_parser_LDADD=${helper_test_LDADD}
|
||||||
|
helper_config_cmdline_parser_SOURCES=\
|
||||||
|
config/config.c\
|
||||||
|
include/rofi.h\
|
||||||
|
include/mode.h\
|
||||||
|
include/mode-private.h\
|
||||||
|
source/helper.c\
|
||||||
|
include/helper.h\
|
||||||
|
include/xrmoptions.h\
|
||||||
|
source/xrmoptions.c\
|
||||||
|
source/x11-helper.c\
|
||||||
|
test/helper-config-cmdline-parser.c
|
||||||
|
|
||||||
TESTS=\
|
TESTS=\
|
||||||
history_test\
|
history_test\
|
||||||
helper_test\
|
helper_test\
|
||||||
helper_expand
|
helper_expand\
|
||||||
|
helper_config_cmdline_parser
|
||||||
|
|
||||||
.PHONY: test-x
|
.PHONY: test-x
|
||||||
test-x: $(bin_PROGRAMS) textbox_test
|
test-x: $(bin_PROGRAMS) textbox_test
|
||||||
|
|
63
test/helper-config-cmdline-parser.c
Normal file
63
test/helper-config-cmdline-parser.c
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <helper.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <xcb/xcb_ewmh.h>
|
||||||
|
#include "xcb-internal.h"
|
||||||
|
#include "rofi.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
static int test = 0;
|
||||||
|
struct xcb_stuff *xcb;
|
||||||
|
|
||||||
|
#define TASSERT( a ) { \
|
||||||
|
assert ( a ); \
|
||||||
|
printf ( "Test %i passed (%s)\n", ++test, # a ); \
|
||||||
|
}
|
||||||
|
#define TASSERTE( a, b ) { \
|
||||||
|
if ( ( a ) == ( b ) ) { \
|
||||||
|
printf ( "Test %i passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
||||||
|
}else { \
|
||||||
|
printf ( "Test %i failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
||||||
|
abort ( ); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||||
|
{
|
||||||
|
fputs ( msg, stderr );
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int show_error_message ( const char *msg, int markup )
|
||||||
|
{
|
||||||
|
rofi_view_error_dialog ( msg, markup );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main ( int argc, char ** argv )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||||
|
fprintf ( stderr, "Failed to set locale.\n" );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
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 );
|
||||||
|
|
||||||
|
}
|
|
@ -49,21 +49,6 @@ int main ( int argc, char ** argv )
|
||||||
fprintf ( stderr, "Failed to set locale.\n" );
|
fprintf ( stderr, "Failed to set locale.\n" );
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
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 );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collating.
|
* Collating.
|
||||||
|
|
Loading…
Reference in a new issue