summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-10-20 09:41:32 +0200
committerDave Davenport <qball@gmpclient.org>2016-10-20 09:41:32 +0200
commit881056ea9b1a606d1d979be631795a3a07d5621e (patch)
treef795dd690a922b7ec851ebff3ce1ac1d0a2d9d7d /test
parentd0d186960454135b8080123404302c741facfd4b (diff)
Add some more tests, make some textbox api's private
Diffstat (limited to 'test')
-rw-r--r--test/helper-test.c20
-rw-r--r--test/textbox-test.c43
2 files changed, 55 insertions, 8 deletions
diff --git a/test/helper-test.c b/test/helper-test.c
index 9d70c61a..4ae5694a 100644
--- a/test/helper-test.c
+++ b/test/helper-test.c
@@ -78,4 +78,24 @@ int main ( int argc, char ** argv )
TASSERTE ( levenshtein ( "aap", "noot aap mies" ), 10 );
TASSERTE ( levenshtein ( "noot aap mies", "aap" ), 10 );
TASSERTE ( levenshtein ( "otp", "noot aap" ), 5 );
+ /**
+ * Quick converision check.
+ */
+ {
+ char *str = rofi_latin_to_utf8_strdup ( "\xA1\xB5", 2);
+ TASSERT ( g_utf8_collate ( str, "¡µ") == 0 );
+ g_free(str);
+ }
+
+ {
+ char *str = rofi_force_utf8("Valid utf8", 10);
+ TASSERT ( g_utf8_collate ( str, "Valid utf8") == 0 );
+ g_free(str);
+ char in[] = "Valid utf8 until \xc3\x28 we continue here";
+ TASSERT ( g_utf8_validate ( in, -1, NULL ) == FALSE );
+ str = rofi_force_utf8(in, strlen(in));
+ TASSERT ( g_utf8_validate ( str, -1, NULL ) == TRUE );
+ TASSERT ( g_utf8_collate ( str, "Valid utf8 until �( we continue here") == 0 );
+ g_free(str);
+ }
}
diff --git a/test/textbox-test.c b/test/textbox-test.c
index 5383e8e9..fc5209ca 100644
--- a/test/textbox-test.c
+++ b/test/textbox-test.c
@@ -57,7 +57,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
NORMAL, "test" );
TASSERT ( box != NULL );
- textbox_cursor_end ( box );
+ textbox_keybinding ( box, MOVE_END );
TASSERT ( box->cursor == 4 );
textbox_cursor ( box, -1 );
TASSERT ( box->cursor == 0 );
@@ -67,7 +67,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
TASSERT ( box->cursor == 2 );
textbox_insert ( box, 3, "bo", 2 );
TASSERT ( strcmp ( box->text, "tesbot" ) == 0 );
- textbox_cursor_end ( box );
+ textbox_keybinding ( box, MOVE_END );
TASSERT ( box->cursor == 6 );
TASSERT ( widget_get_width ( WIDGET ( box ) ) > 0 );
@@ -78,19 +78,19 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
TASSERT ( textbox_get_estimated_char_width ( ) > 0 );
- textbox_cursor_bkspc ( box );
+ textbox_keybinding ( box, REMOVE_CHAR_BACK );
TASSERT ( strcmp ( box->text, "tesbo" ) == 0 );
TASSERT ( box->cursor == 5 );
- textbox_cursor_dec ( box );
+ textbox_keybinding ( box, MOVE_CHAR_BACK );
TASSERT ( box->cursor == 4 );
- textbox_cursor_del ( box );
+ textbox_keybinding ( box, REMOVE_CHAR_FORWARD );
TASSERT ( strcmp ( box->text, "tesb" ) == 0 );
- textbox_cursor_dec ( box );
+ textbox_keybinding ( box, MOVE_CHAR_BACK );
TASSERT ( box->cursor == 3 );
- textbox_cursor_inc ( box );
+ textbox_keybinding ( box, MOVE_CHAR_FORWARD);
TASSERT ( box->cursor == 4 );
- textbox_cursor_inc ( box );
+ textbox_keybinding ( box, MOVE_CHAR_FORWARD);
TASSERT ( box->cursor == 4 );
// Cursor after delete section.
textbox_delete ( box, 0, 1 );
@@ -122,6 +122,33 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
TASSERT ( box->cursor == 5 );
+
+ textbox_text ( box, "aap noot mies");
+ textbox_cursor ( box, 8 );
+ textbox_keybinding ( box, REMOVE_WORD_BACK );
+ TASSERT ( box->cursor == 4);
+ TASSERT ( strcmp ( box->text, "aap mies") == 0 );
+ textbox_keybinding ( box, REMOVE_TO_EOL );
+ TASSERT ( box->cursor == 4);
+ TASSERT ( strcmp ( box->text, "aap ") == 0 );
+ textbox_text ( box, "aap noot mies");
+ textbox_cursor ( box, 8 );
+ textbox_keybinding ( box, REMOVE_WORD_FORWARD );
+ TASSERT ( strcmp ( box->text, "aap noot") == 0 );
+ textbox_keybinding ( box, MOVE_FRONT );
+ TASSERT ( box->cursor == 0);
+ textbox_keybinding ( box, CLEAR_LINE );
+ TASSERT ( strcmp ( box->text, "") == 0 );
+ textbox_text ( box, "aap noot mies");
+ textbox_keybinding ( box, MOVE_END);
+ textbox_keybinding ( box, MOVE_WORD_BACK );
+ TASSERT ( box->cursor == 9);
+ textbox_keybinding ( box, MOVE_WORD_BACK );
+ TASSERT ( box->cursor == 4);
+ textbox_keybinding ( box, REMOVE_TO_SOL );
+ TASSERT ( strcmp ( box->text, "noot mies") == 0 );
+ TASSERT ( box->cursor == 0);
+
textbox_font ( box, HIGHLIGHT );
//textbox_draw ( box, draw );