7 #include "test-helper.h"
9 #define DEBUG_FLAG EMPATHY_DEBUG_TESTS
10 #include <libempathy/empathy-debug.h>
12 #include <libempathy-gtk/empathy-live-search.h>
18 gboolean should_match;
22 test_live_search (void)
24 LiveSearchTest tests[] =
26 /* Test word separators and case */
27 { "Hello World", "he", TRUE },
28 { "Hello World", "wo", TRUE },
29 { "Hello World", "lo", FALSE },
30 { "Hello World", "ld", FALSE },
31 { "Hello-World", "wo", TRUE },
32 { "HelloWorld", "wo", FALSE },
34 /* Test composed chars (accentued letters) */
35 { "Jörgen", "jor", TRUE },
36 { "Gaëtan", "gaetan", TRUE },
37 { "élève", "ele", TRUE },
38 { "Azais", "AzaÏs", TRUE },
40 /* Test decomposed chars, they looks the same, but are actually
41 * composed of multiple unicodes */
42 { "Jorgen", "Jör", TRUE },
43 { "Jörgen", "jor", TRUE },
46 { "Xavier Claessens", "Xav Cla", TRUE },
47 { "Xavier Claessens", "Cla Xav", TRUE },
48 { "Foo Bar Baz", " b ", TRUE },
49 { "Foo Bar Baz", "bar bazz", FALSE },
56 for (i = 0; tests[i].string != NULL; i ++)
61 match = empathy_live_search_match_string (tests[i].string, tests[i].prefix);
62 ok = (match == tests[i].should_match);
64 DEBUG ("'%s' - '%s' %s: %s", tests[i].string, tests[i].prefix,
65 tests[i].should_match ? "should match" : "should NOT match",
66 ok ? "OK" : "FAILED");
78 test_init (argc, argv);
80 g_test_add_func ("/live-search", test_live_search);
82 result = g_test_run ();