summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-01-04 20:56:54 +0100
committerDave Davenport <qball@gmpclient.org>2016-01-04 20:56:54 +0100
commitfefd992c11313732de59cca1a8178474954804d8 (patch)
tree2b17b9263888912610eb91a75564a7514f860b87 /test
parentf715a33bf7ec153bb6bb2b3fa1e9e38415b67352 (diff)
parent09c7b330260ea510cb7db98b0cf330724d6a2e93 (diff)
Merge branch 'master' of github:DaveDavenport/rofi
Diffstat (limited to 'test')
-rw-r--r--test/helper-test.c19
-rwxr-xr-xtest/run_dmenu_normal_window_test.sh26
-rwxr-xr-xtest/run_fuzzy_test.sh22
3 files changed, 66 insertions, 1 deletions
diff --git a/test/helper-test.c b/test/helper-test.c
index a5b98903..1e4d9f55 100644
--- a/test/helper-test.c
+++ b/test/helper-test.c
@@ -7,10 +7,18 @@
static int test = 0;
-#define TASSERT( a ) { \
+#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 ( ); \
+ } \
+}
void error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
@@ -127,4 +135,13 @@ int main ( int argc, char ** argv )
TASSERT ( retv[2] && strcmp ( retv[2], "bEp" ) == 0 );
TASSERT ( retv[3] && strcmp ( retv[3], "bEE" ) == 0 );
tokenize_free ( retv );
+
+ TASSERT ( levenshtein ( "aap", "aap" ) == 0 );
+ TASSERT ( levenshtein ( "aap", "aap " ) == 1 );
+ TASSERT ( levenshtein ( "aap ", "aap" ) == 1 );
+ TASSERTE ( levenshtein ( "aap", "aap noot" ), 5 );
+ TASSERTE ( levenshtein ( "aap", "noot aap" ), 5 );
+ TASSERTE ( levenshtein ( "aap", "noot aap mies" ), 10 );
+ TASSERTE ( levenshtein ( "noot aap mies", "aap" ), 10 );
+ TASSERTE ( levenshtein ( "otp", "noot aap" ), 5 );
}
diff --git a/test/run_dmenu_normal_window_test.sh b/test/run_dmenu_normal_window_test.sh
new file mode 100755
index 00000000..2fb731ef
--- /dev/null
+++ b/test/run_dmenu_normal_window_test.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+# wait till it is up, run rofi with error message
+sleep 1;
+echo -e -n "aap\nnoot\nmies" | rofi -dmenu -normal-window > output.txt &
+RPID=$!
+sleep 4
+xdotool getactivewindow windowsize 100% 100%
+# send enter.
+sleep 1
+xdotool key 'Down'
+sleep 0.4
+xdotool key Shift+Return
+xdotool key Return
+
+# Get result, kill xvfb
+wait ${RPID}
+RETV=$?
+OUTPUT=$(cat output.txt | tr '\n' ' ')
+if [ "${OUTPUT}" != 'noot mies ' ]
+then
+ echo "Got: '${OUTPUT}' expected 'noot mies '"
+ exit 1
+fi
+echo ${RETV}
+exit ${RETV}
diff --git a/test/run_fuzzy_test.sh b/test/run_fuzzy_test.sh
new file mode 100755
index 00000000..e7e5d81a
--- /dev/null
+++ b/test/run_fuzzy_test.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+echo -en "nooty\naap\nnoot\nmies" | rofi -fuzzy -dmenu > output.txt &
+RPID=$!
+
+# send enter.
+sleep 5;
+xdotool type 'nty'
+sleep 0.4
+xdotool key Return
+
+# Get result, kill xvfb
+wait ${RPID}
+RETV=$?
+OUTPUT=$(cat output.txt)
+if [ "${OUTPUT}" != 'nooty' ]
+then
+ echo "Got: '${OUTPUT}' expected 'nooty'"
+ exit 1
+fi
+
+exit ${RETV}