]> git.0d.be Git - empathy.git/blob - tests/empathy-live-search-test.c
add GTK+ flags when building tests
[empathy.git] / tests / empathy-live-search-test.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "test-helper.h"
6
7 #define DEBUG_FLAG EMPATHY_DEBUG_TESTS
8 #include <libempathy/empathy-debug.h>
9
10 #include <libempathy-gtk/empathy-live-search.h>
11
12 typedef struct
13 {
14   const gchar *string;
15   const gchar *prefix;
16   gboolean should_match;
17 } LiveSearchTest;
18
19 static void
20 test_live_search (void)
21 {
22   LiveSearchTest tests[] =
23     {
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 },
31
32       /* Test accentued letters */
33       { "Jörgen", "jor", TRUE },
34       { "Gaëtan", "gaetan", TRUE },
35       { "élève", "ele", TRUE },
36       { "Azais", "AzaÏs", TRUE },
37
38       { NULL, NULL, FALSE }
39     };
40   guint i;
41   gboolean failed = FALSE;
42
43   DEBUG ("Started");
44   for (i = 0; tests[i].string != NULL; i ++)
45     {
46       gboolean match;
47       gboolean ok;
48
49       match = empathy_live_search_match_string (tests[i].string, tests[i].prefix);
50       ok = (match == tests[i].should_match);
51
52       DEBUG ("'%s' - '%s': %s", tests[i].string, tests[i].prefix, ok ? "OK" : "FAILED");
53
54       if (!ok)
55         failed = TRUE;
56     }
57
58   g_assert (!failed);
59 }
60
61 int
62 main (int argc,
63     char **argv)
64 {
65   int result;
66
67   test_init (argc, argv);
68
69   g_test_add_func ("/live-search", test_live_search);
70
71   result = g_test_run ();
72   test_deinit ();
73
74   return result;
75 }