6 #include <tp-account-widgets/tpaw-live-search.h>
8 #include "test-helper.h"
10 #define DEBUG_FLAG EMPATHY_DEBUG_TESTS
11 #include "empathy-debug.h"
17 gboolean should_match
;
21 test_live_search (void)
23 LiveSearchTest tests
[] =
25 /* Test word separators and case */
26 { "Hello World", "he", TRUE
},
27 { "Hello World", "wo", TRUE
},
28 { "Hello World", "lo", FALSE
},
29 { "Hello World", "ld", FALSE
},
30 { "Hello-World", "wo", TRUE
},
31 { "HelloWorld", "wo", FALSE
},
33 /* Test composed chars (accentued letters) */
34 { "Jörgen", "jor", TRUE
},
35 { "Gaëtan", "gaetan", TRUE
},
36 { "élève", "ele", TRUE
},
37 { "Azais", "AzaÏs", TRUE
},
39 /* Test decomposed chars, they looks the same, but are actually
40 * composed of multiple unicodes */
41 { "Jorgen", "Jör", TRUE
},
42 { "Jörgen", "jor", TRUE
},
45 { "Xavier Claessens", "Xav Cla", TRUE
},
46 { "Xavier Claessens", "Cla Xav", TRUE
},
47 { "Foo Bar Baz", " b ", TRUE
},
48 { "Foo Bar Baz", "bar bazz", FALSE
},
55 for (i
= 0; tests
[i
].string
!= NULL
; i
++)
60 match
= tpaw_live_search_match_string (tests
[i
].string
, tests
[i
].prefix
);
61 ok
= (match
== tests
[i
].should_match
);
63 DEBUG ("'%s' - '%s' %s: %s", tests
[i
].string
, tests
[i
].prefix
,
64 tests
[i
].should_match
? "should match" : "should NOT match",
65 ok
? "OK" : "FAILED");
77 test_init (argc
, argv
);
79 g_test_add_func ("/live-search", test_live_search
);
81 result
= g_test_run ();