Updated Spanish translation
[empathy-mirror.git] / tests / empathy-live-search-test.c
blob2f02468d08af8c0fdec07bda60761e85df246757
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
5 #include "test-helper.h"
7 #define DEBUG_FLAG EMPATHY_DEBUG_TESTS
8 #include <libempathy/empathy-debug.h>
10 #include <libempathy-gtk/empathy-live-search.h>
12 typedef struct
14 const gchar *string;
15 const gchar *prefix;
16 gboolean should_match;
17 } LiveSearchTest;
19 static void
20 test_live_search (void)
22 LiveSearchTest tests[] =
24 /* Test word separators and case */
25 { "Hello World", "he", TRUE },
26 { "Hello World", "wo", TRUE },
27 { "Hello World", "lo", FALSE },
28 { "Hello World", "ld", FALSE },
29 { "Hello-World", "wo", TRUE },
30 { "HelloWorld", "wo", FALSE },
32 /* Test composed chars (accentued letters) */
33 { "Jörgen", "jor", TRUE },
34 { "Gaëtan", "gaetan", TRUE },
35 { "élève", "ele", TRUE },
36 { "Azais", "AzaÏs", TRUE },
38 /* Test decomposed chars, they looks the same, but are actually
39 * composed of multiple unicodes */
40 { "Jorgen", "Jör", TRUE },
41 { "Jörgen", "jor", TRUE },
43 /* Multi words */
44 { "Xavier Claessens", "Xav Cla", TRUE },
45 { "Xavier Claessens", "Cla Xav", TRUE },
46 { "Foo Bar Baz", " b ", TRUE },
47 { "Foo Bar Baz", "bar bazz", FALSE },
49 { NULL, NULL, FALSE }
51 guint i;
53 DEBUG ("Started");
54 for (i = 0; tests[i].string != NULL; i ++)
56 gboolean match;
57 gboolean ok;
59 match = empathy_live_search_match_string (tests[i].string, tests[i].prefix);
60 ok = (match == tests[i].should_match);
62 DEBUG ("'%s' - '%s' %s: %s", tests[i].string, tests[i].prefix,
63 tests[i].should_match ? "should match" : "should NOT match",
64 ok ? "OK" : "FAILED");
66 g_assert (ok);
70 int
71 main (int argc,
72 char **argv)
74 int result;
76 test_init (argc, argv);
78 g_test_add_func ("/live-search", test_live_search);
80 result = g_test_run ();
81 test_deinit ();
83 return result;