summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am6
-rw-r--r--source/rofi.c2
-rw-r--r--test/helper-test.c34
-rw-r--r--test/history-test.c83
-rw-r--r--test/textbox-test.c129
5 files changed, 127 insertions, 127 deletions
diff --git a/Makefile.am b/Makefile.am
index 5174e8e4..71d33fd1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,8 +104,6 @@ EXTRA_DIST=\
# Indent
##
-indent: ${rofi_SOURCES} ${top_srcdir}/config/config.def.c
- uncrustify -c ${top_srcdir}/data/uncrustify.cfg --replace $^
update-manpage: ${top_srcdir}/doc/rofi-manpage.markdown
ronn --roff --pipe $^ > ${top_srcdir}/doc/rofi.1
@@ -163,6 +161,10 @@ test-x: ${bin_PROGRAMS}
$(top_srcdir)/test/run_test.sh 205 $(top_srcdir)/test/run_script_test.sh $(top_builddir) $(top_srcdir)/doc/example.xresources
+.PHONY: indent
+indent: ${rofi_SOURCES} ${top_srcdir}/config/config.def.c ${helper_test_SOURCES} ${textbox_test_SOURCES} ${rofi_test_SOURCES}
+ uncrustify -c ${top_srcdir}/data/uncrustify.cfg --replace $^
+
.PHONY: cppcheck
cppcheck: ${rofi_SOURCES}
diff --git a/source/rofi.c b/source/rofi.c
index a2d1656f..ea2e50f1 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -1057,7 +1057,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
// TODO calculate from top.
textbox_move ( state.arrowbox_bottom,
state.w - config.padding - state.arrowbox_bottom->w,
- state.top_offset + (state.max_rows-1) * element_height + LINE_MARGIN );
+ state.top_offset + ( state.max_rows - 1 ) * element_height + LINE_MARGIN );
// filtered list
state.line_map = g_malloc0_n ( state.num_lines, sizeof ( int ) );
diff --git a/test/helper-test.c b/test/helper-test.c
index bbebd7b7..15bd2def 100644
--- a/test/helper-test.c
+++ b/test/helper-test.c
@@ -6,26 +6,26 @@
static int test = 0;
-#define TASSERT(a) {\
- assert ( a );\
- printf("Test %i passed (%s)\n", ++test, #a);\
+#define TASSERT( a ) { \
+ assert ( a ); \
+ printf ( "Test %i passed (%s)\n", ++test, # a ); \
}
int main ( int argc, char ** argv )
{
- cmd_set_arguments(argc, 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);
+ cmd_set_arguments ( argc, 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 );
+ 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);
+ g_strfreev ( list );
}
diff --git a/test/history-test.c b/test/history-test.c
index c72ba8a0..cd649cf9 100644
--- a/test/history-test.c
+++ b/test/history-test.c
@@ -9,85 +9,84 @@
static int test = 0;
-#define TASSERT(a) {\
- assert ( a );\
- printf("Test %i passed (%s)\n", ++test, #a);\
+#define TASSERT( a ) { \
+ assert ( a ); \
+ printf ( "Test %i passed (%s)\n", ++test, # a ); \
}
const char *file = "text";
-static void history_test( void )
+static void history_test ( void )
{
- unlink(file);
+ unlink ( file );
// Empty list.
- unsigned int length= 0;
- char **retv = history_get_list ( file, &length);
+ unsigned int length = 0;
+ char **retv = history_get_list ( file, &length );
- TASSERT ( retv == NULL );
- TASSERT ( length == 0 );
+ TASSERT ( retv == NULL );
+ TASSERT ( length == 0 );
// 1 item
- history_set( file, "aap");
+ history_set ( file, "aap" );
- retv = history_get_list ( file, &length);
+ retv = history_get_list ( file, &length );
- TASSERT ( retv != NULL );
- TASSERT ( length == 1 );
+ TASSERT ( retv != NULL );
+ TASSERT ( length == 1 );
- TASSERT ( strcmp(retv[0], "aap") == 0 );
+ TASSERT ( strcmp ( retv[0], "aap" ) == 0 );
- g_strfreev(retv);
+ g_strfreev ( retv );
// Remove entry
history_remove ( file, "aap" );
- length= 0;
- retv = history_get_list ( file, &length);
+ length = 0;
+ retv = history_get_list ( file, &length );
- TASSERT ( retv == NULL );
- TASSERT ( length == 0 );
+ TASSERT ( retv == NULL );
+ TASSERT ( length == 0 );
// 2 items
- history_set( file, "aap");
- history_set( file, "aap");
+ history_set ( file, "aap" );
+ history_set ( file, "aap" );
- retv = history_get_list ( file, &length);
+ retv = history_get_list ( file, &length );
- TASSERT ( retv != NULL );
- TASSERT ( length == 1 );
+ TASSERT ( retv != NULL );
+ TASSERT ( length == 1 );
- TASSERT ( strcmp(retv[0], "aap") == 0 );
+ TASSERT ( strcmp ( retv[0], "aap" ) == 0 );
- g_strfreev(retv);
+ g_strfreev ( retv );
- for(unsigned int in=length+1; in < 26; in++) {
- char *p = g_strdup_printf("aap%i", in);
- printf("%s- %d\n",p, in);
- history_set( file, p);
- retv = history_get_list ( file, &length);
+ for ( unsigned int in = length + 1; in < 26; in++ ) {
+ char *p = g_strdup_printf ( "aap%i", in );
+ printf ( "%s- %d\n", p, in );
+ history_set ( file, p );
+ retv = history_get_list ( file, &length );
- TASSERT ( retv != NULL );
- TASSERT ( length == (in) );
+ TASSERT ( retv != NULL );
+ TASSERT ( length == ( in ) );
- g_strfreev(retv);
+ g_strfreev ( retv );
- g_free(p);
+ g_free ( p );
}
// Max 25 entries.
- history_set( file, "blaat" );
- retv = history_get_list ( file, &length);
+ history_set ( file, "blaat" );
+ retv = history_get_list ( file, &length );
- TASSERT ( retv != NULL );
- TASSERT ( length == 25 );
-
- g_strfreev(retv);
+ TASSERT ( retv != NULL );
+ TASSERT ( length == 25 );
+ g_strfreev ( retv );
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
- history_test();
+ history_test ();
return 0;
}
diff --git a/test/textbox-test.c b/test/textbox-test.c
index b44199c0..b9de109c 100644
--- a/test/textbox-test.c
+++ b/test/textbox-test.c
@@ -15,13 +15,13 @@
static int test = 0;
-#define TASSERT(a) {\
- assert ( a );\
- printf("Test %3i passed (%s)\n", ++test, #a);\
+#define TASSERT( a ) { \
+ assert ( a ); \
+ printf ( "Test %3i passed (%s)\n", ++test, # a ); \
}
-Display *display = NULL;
-Colormap map = None;
+Display *display = NULL;
+Colormap map = None;
XVisualInfo vinfo;
static unsigned int color_get ( Display *display, const char *const name )
@@ -36,129 +36,128 @@ static unsigned int color_get ( Display *display, const char *const name )
}
}
-static void create_visual_and_colormap()
+static void create_visual_and_colormap ()
{
map = None;
// Try to create TrueColor map
- if(XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo )) {
+ if ( XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo ) ) {
// Visual found, lets try to create map.
map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone );
}
// Failed to create map.
- if (map == None ) {
+ if ( map == None ) {
// Two fields we use.
- vinfo.visual = DefaultVisual(display, DefaultScreen(display));
- vinfo.depth = DefaultDepth(display, DefaultScreen(display));
- map = DefaultColormap( display, DefaultScreen (display));
+ vinfo.visual = DefaultVisual ( display, DefaultScreen ( display ) );
+ vinfo.depth = DefaultDepth ( display, DefaultScreen ( display ) );
+ map = DefaultColormap ( display, DefaultScreen ( display ) );
}
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
-
// Get DISPLAY
const char *display_str = getenv ( "DISPLAY" );
if ( !( display = XOpenDisplay ( display_str ) ) ) {
fprintf ( stderr, "cannot open display!\n" );
return EXIT_FAILURE;
}
- create_visual_and_colormap();
+ create_visual_and_colormap ();
- setup_abe();
- TASSERT( display != NULL );
+ setup_abe ();
+ TASSERT ( display != NULL );
XSetWindowAttributes attr;
attr.colormap = map;
attr.border_pixel = color_get ( display, "white" );
- attr.background_pixel = color_get ( display, "black");
+ attr.background_pixel = color_get ( display, "black" );
Window mw = XCreateWindow ( display, DefaultRootWindow ( display ),
- 0, 0, 200, 100, config.menu_bw, vinfo.depth, InputOutput,
- vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, &attr );
- TASSERT( mw != None );
+ 0, 0, 200, 100, config.menu_bw, vinfo.depth, InputOutput,
+ vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, &attr );
+ TASSERT ( mw != None );
// Set alternate row to normal row.
config.menu_bg_alt = config.menu_bg;
textbox_setup ( &vinfo, map );
- textbox *box = textbox_create(mw , &vinfo, map, TB_EDITABLE|TB_AUTOWIDTH|TB_AUTOHEIGHT, 0,0, -1, -1, NORMAL, "test");
- TASSERT( box != NULL );
+ textbox *box = textbox_create ( mw, &vinfo, map, TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, 0, 0, -1, -1, NORMAL, "test" );
+ TASSERT ( box != NULL );
textbox_cursor_end ( box );
- TASSERT ( box->cursor == 4);
+ TASSERT ( box->cursor == 4 );
textbox_cursor ( box, -1 );
TASSERT ( box->cursor == 0 );
textbox_cursor ( box, 8 );
TASSERT ( box->cursor == 4 );
textbox_cursor ( box, 2 );
TASSERT ( box->cursor == 2 );
- textbox_insert ( box, 3, "bo");
- TASSERT ( strcmp(box->text, "tesbot") == 0 );
+ textbox_insert ( box, 3, "bo" );
+ TASSERT ( strcmp ( box->text, "tesbot" ) == 0 );
textbox_cursor_end ( box );
- TASSERT ( box->cursor == 6);
+ TASSERT ( box->cursor == 6 );
- TASSERT( textbox_get_width( box) > 0 );
- TASSERT( textbox_get_height( box) > 0 );
+ TASSERT ( textbox_get_width ( box ) > 0 );
+ TASSERT ( textbox_get_height ( box ) > 0 );
- TASSERT( textbox_get_width( box) >= textbox_get_font_width( box) );
- TASSERT( textbox_get_height( box) >= textbox_get_font_height( box) );
+ TASSERT ( textbox_get_width ( box ) >= textbox_get_font_width ( box ) );
+ TASSERT ( textbox_get_height ( box ) >= textbox_get_font_height ( box ) );
- TASSERT( textbox_get_estimated_char_width ( ) > 0 );
+ TASSERT ( textbox_get_estimated_char_width ( ) > 0 );
textbox_cursor_bkspc ( box );
- TASSERT ( strcmp(box->text, "tesbo") == 0 );
- TASSERT ( box->cursor == 5);
+ TASSERT ( strcmp ( box->text, "tesbo" ) == 0 );
+ TASSERT ( box->cursor == 5 );
textbox_cursor_dec ( box );
- TASSERT ( box->cursor == 4);
+ TASSERT ( box->cursor == 4 );
textbox_cursor_del ( box );
- TASSERT ( strcmp(box->text, "tesb") == 0 );
+ TASSERT ( strcmp ( box->text, "tesb" ) == 0 );
textbox_cursor_dec ( box );
- TASSERT ( box->cursor == 3);
+ TASSERT ( box->cursor == 3 );
textbox_cursor_inc ( box );
- TASSERT ( box->cursor == 4);
+ TASSERT ( box->cursor == 4 );
textbox_cursor_inc ( box );
- TASSERT ( box->cursor == 4);
+ TASSERT ( box->cursor == 4 );
// Cursor after delete section.
textbox_delete ( box, 0, 1 );
- TASSERT ( strcmp(box->text, "esb") == 0 );
- TASSERT ( box->cursor == 3);
+ TASSERT ( strcmp ( box->text, "esb" ) == 0 );
+ TASSERT ( box->cursor == 3 );
// Cursor before delete.
- textbox_text( box, "aap noot mies");
- TASSERT ( strcmp(box->text, "aap noot mies") == 0 );
- textbox_cursor( box, 3 );
- TASSERT ( box->cursor == 3);
+ textbox_text ( box, "aap noot mies" );
+ TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
+ textbox_cursor ( box, 3 );
+ TASSERT ( box->cursor == 3 );
textbox_delete ( box, 3, 6 );
- TASSERT ( strcmp(box->text, "aapmies") == 0 );
- TASSERT ( box->cursor == 3);
+ TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
+ TASSERT ( box->cursor == 3 );
// Cursor within delete
- textbox_text( box, "aap noot mies");
- TASSERT ( strcmp(box->text, "aap noot mies") == 0 );
- textbox_cursor( box, 5 );
- TASSERT ( box->cursor == 5);
+ textbox_text ( box, "aap noot mies" );
+ TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
+ textbox_cursor ( box, 5 );
+ TASSERT ( box->cursor == 5 );
textbox_delete ( box, 3, 6 );
- TASSERT ( strcmp(box->text, "aapmies") == 0 );
- TASSERT ( box->cursor == 3);
+ TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
+ TASSERT ( box->cursor == 3 );
// Cursor after delete.
- textbox_text( box, "aap noot mies");
- TASSERT ( strcmp(box->text, "aap noot mies") == 0 );
- textbox_cursor( box, 11 );
- TASSERT ( box->cursor == 11);
+ textbox_text ( box, "aap noot mies" );
+ TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
+ textbox_cursor ( box, 11 );
+ TASSERT ( box->cursor == 11 );
textbox_delete ( box, 3, 6 );
- TASSERT ( strcmp(box->text, "aapmies") == 0 );
- TASSERT ( box->cursor == 5);
+ TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
+ TASSERT ( box->cursor == 5 );
textbox_font ( box, HIGHLIGHT );
- textbox_draw( box);
+ textbox_draw ( box );
- textbox_show( box );
- textbox_move ( box, 12, 13);
+ textbox_show ( box );
+ textbox_move ( box, 12, 13 );
TASSERT ( box->x == 12 );
TASSERT ( box->y == 13 );
- textbox_hide( box );
+ textbox_hide ( box );
- textbox_free(box);
- textbox_cleanup( );
+ textbox_free ( box );
+ textbox_cleanup ( );
- cleanup_abe();
+ cleanup_abe ();
- XDestroyWindow ( display, mw);
+ XDestroyWindow ( display, mw );
XCloseDisplay ( display );
}