2
* Copyright (C) 2012 Canonical, Ltd.
4
* This library is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License
6
* version 3.0 as published by the Free Software Foundation.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License version 3.0 for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library. If not, see
15
* <http://www.gnu.org/licenses/>.
17
* Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
25
DeeICUTermFilter *filter;
28
static void setup (Fixture *fix, gconstpointer data);
29
static void teardown (Fixture *fix, gconstpointer data);
32
setup (Fixture *fix, gconstpointer data)
38
teardown (Fixture *fix, gconstpointer data)
41
dee_icu_term_filter_destroy (fix->filter);
45
test_ascii_folder (Fixture *fix, gconstpointer data)
49
fix->filter = dee_icu_term_filter_new_ascii_folder();
51
result = dee_icu_term_filter_apply (fix->filter, "Hello world");
52
g_assert_cmpstr (result, ==, "Hello world");
55
result = dee_icu_term_filter_apply (fix->filter, "øöô");
56
g_assert_cmpstr (result, ==, "ooo");
59
result = dee_icu_term_filter_apply (fix->filter, "Θεοδωράτου, Ελένη");
60
g_assert_cmpstr (result, ==, "Theodoratou, Elene");
63
result = dee_icu_term_filter_apply (fix->filter, "Догилева, Татьяна");
64
g_assert_cmpstr (result, ==, "Dogileva, Tatʹana");
67
result = dee_icu_term_filter_apply (fix->filter, "김, 국삼");
68
g_assert_cmpstr (result, ==, "gim, gugsam");
71
result = dee_icu_term_filter_apply (fix->filter, "たけだ, まさゆき");
72
g_assert_cmpstr (result, ==, "takeda, masayuki");
75
/* One last time to honor the French ;-) */
76
result = dee_icu_term_filter_apply (fix->filter, "Est-ce que tes enfants sont de bons élèves? Ça va pour eux?");
77
g_assert_cmpstr (result, ==, "Est-ce que tes enfants sont de bons eleves? Ca va pour eux?");
82
test_bad_id (Fixture *fix, gconstpointer data)
86
fix->filter = dee_icu_term_filter_new ("*-sad ???", NULL, &error);
88
g_assert (fix->filter == NULL);
89
g_assert (error != NULL);
90
g_assert_cmpint (error->domain, ==, DEE_ICU_ERROR);
91
g_assert_cmpint (error->code, ==, DEE_ICU_ERROR_BAD_ID);
97
test_bad_rule (Fixture *fix, gconstpointer data)
101
fix->filter = dee_icu_term_filter_new (NULL, "*-sad ???", &error);
103
g_assert (fix->filter == NULL);
104
g_assert (error != NULL);
105
g_assert_cmpint (error->domain, ==, DEE_ICU_ERROR);
106
g_assert_cmpint (error->code, ==, DEE_ICU_ERROR_BAD_RULE);
108
g_error_free (error);
112
test_icu_create_suite (void)
114
#define DOMAIN "/ICU/TermFilter"
116
g_test_add (DOMAIN"/Default/AsciiFolder", Fixture, 0,
117
setup, test_ascii_folder, teardown);
118
g_test_add (DOMAIN"/Default/BadId", Fixture, 0,
119
setup, test_bad_id, teardown);
120
g_test_add (DOMAIN"/Default/BadRule", Fixture, 0,
121
setup, test_bad_rule, teardown);