aboutsummaryrefslogtreecommitdiffstats
path: root/tests/empathy-live-search-test.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2010-06-08 23:15:03 +0800
committerXavier Claessens <xclaesse@gmail.com>2010-06-08 23:22:03 +0800
commite804261f77cf34814c56e947cd2667aff9d544cf (patch)
tree8af89fd30db4d10fc8510fafe6817c5c778a31bc /tests/empathy-live-search-test.c
parentd4e8ed896d085e3ad76c07861a93c3366d34f340 (diff)
downloadgsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.tar
gsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.tar.gz
gsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.tar.bz2
gsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.tar.lz
gsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.tar.xz
gsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.tar.zst
gsoc2013-empathy-e804261f77cf34814c56e947cd2667aff9d544cf.zip
Add unit test for the live search matching
Diffstat (limited to 'tests/empathy-live-search-test.c')
-rw-r--r--tests/empathy-live-search-test.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/empathy-live-search-test.c b/tests/empathy-live-search-test.c
new file mode 100644
index 000000000..6263481a2
--- /dev/null
+++ b/tests/empathy-live-search-test.c
@@ -0,0 +1,75 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "test-helper.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_TESTS
+#include <libempathy/empathy-debug.h>
+
+#include <libempathy-gtk/empathy-live-search.h>
+
+typedef struct
+{
+ const gchar *string;
+ const gchar *prefix;
+ gboolean should_match;
+} LiveSearchTest;
+
+static void
+test_live_search (void)
+{
+ LiveSearchTest tests[] =
+ {
+ /* Test word separators and case */
+ { "Hello World", "he", TRUE },
+ { "Hello World", "wo", TRUE },
+ { "Hello World", "lo", FALSE },
+ { "Hello World", "ld", FALSE },
+ { "Hello-World", "wo", TRUE },
+ { "HelloWorld", "wo", FALSE },
+
+ /* Test accentued letters */
+ { "Jörgen", "jor", TRUE },
+ { "Gaëtan", "gaetan", TRUE },
+ { "élève", "ele", TRUE },
+ { "Azais", "AzaÏs", TRUE },
+
+ { NULL, NULL, FALSE }
+ };
+ guint i;
+ gboolean failed = FALSE;
+
+ DEBUG ("Started");
+ for (i = 0; tests[i].string != NULL; i ++)
+ {
+ gboolean match;
+ gboolean ok;
+
+ match = empathy_live_search_match_string (tests[i].string, tests[i].prefix);
+ ok = (match == tests[i].should_match);
+
+ DEBUG ("'%s' - '%s': %s", tests[i].string, tests[i].prefix, ok ? "OK" : "FAILED");
+
+ if (!ok)
+ failed = TRUE;
+ }
+
+ g_assert (!failed);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ int result;
+
+ test_init (argc, argv);
+
+ g_test_add_func ("/live-search", test_live_search);
+
+ result = g_test_run ();
+ test_deinit ();
+
+ return result;
+}