[glib] Remove duplicate utf8 strreverse test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Remove duplicate utf8 strreverse test
- Date: Fri, 30 Jul 2010 23:58:09 +0000 (UTC)
commit 154880b2ad9064ac78c8e1d55a2ae96bf48d159a
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jul 27 18:21:15 2010 -0400
Remove duplicate utf8 strreverse test
Also add some tests for find next/prev char.
glib/tests/utf8-misc.c | 18 ++++++++++++++++++
glib/tests/utf8-pointer.c | 41 ++++++++++++++++++++++++++++++++---------
2 files changed, 50 insertions(+), 9 deletions(-)
---
diff --git a/glib/tests/utf8-misc.c b/glib/tests/utf8-misc.c
index be9e00d..dfa7ebb 100644
--- a/glib/tests/utf8-misc.c
+++ b/glib/tests/utf8-misc.c
@@ -408,6 +408,23 @@ test_mark (void)
g_assert (!g_unichar_ismark ('a'));
}
+static void
+test_title (void)
+{
+ g_assert (g_unichar_istitle (0x01c5));
+ g_assert (g_unichar_istitle (0x1f88));
+ g_assert (g_unichar_istitle (0x1fcc));
+ g_assert (!g_unichar_ismark ('a'));
+
+ g_assert (g_unichar_totitle (0x01c6) == 0x01c5);
+ g_assert (g_unichar_totitle (0x01c4) == 0x01c5);
+ g_assert (g_unichar_totitle (0x01c5) == 0x01c5);
+ g_assert (g_unichar_totitle (0x1f80) == 0x1f88);
+ g_assert (g_unichar_totitle (0x1f88) == 0x1f88);
+ g_assert (g_unichar_totitle ('a') == 'A');
+ g_assert (g_unichar_totitle ('A') == 'A');
+}
+
int
main (int argc,
char *argv[])
@@ -425,6 +442,7 @@ main (int argc,
g_test_add_func ("/unicode/combining-class", test_combining_class);
g_test_add_func ("/unicode/mirror", test_mirror);
g_test_add_func ("/unicode/mark", test_mark);
+ g_test_add_func ("/unicode/title", test_title);
return g_test_run();
}
diff --git a/glib/tests/utf8-pointer.c b/glib/tests/utf8-pointer.c
index 2c5e386..6ef27d3 100644
--- a/glib/tests/utf8-pointer.c
+++ b/glib/tests/utf8-pointer.c
@@ -92,15 +92,38 @@ test_length (void)
}
static void
-test_misc (void)
+test_find (void)
{
- char *s;
- s = g_utf8_strreverse ("1234", -1);
- g_assert (strcmp (s, "4321") == 0);
- g_free (s);
- s = g_utf8_strreverse ("1234", 3);
- g_assert (strcmp (s, "321") == 0);
- g_free (s);
+ /* U+0B0B Oriya Letter Vocalic R (\340\254\213)
+ * U+10900 Phoenician Letter Alf (\360\220\244\200)
+ * U+0041 Latin Capital Letter A (\101)
+ * U+1EB6 Latin Capital Letter A With Breve And Dot Below (\341\272\266)
+ */
+ const gchar *str = "\340\254\213\360\220\244\200\101\341\272\266";
+ const gchar *p = str + strlen (str);
+ const gchar *q;
+
+ q = g_utf8_find_prev_char (str, p);
+ g_assert (q == str + 8);
+ q = g_utf8_find_prev_char (str, q);
+ g_assert (q == str + 7);
+ q = g_utf8_find_prev_char (str, q);
+ g_assert (q == str + 3);
+ q = g_utf8_find_prev_char (str, q);
+ g_assert (q == str);
+ q = g_utf8_find_prev_char (str, q);
+ g_assert (q == NULL);
+
+ p = str + 2;
+ q = g_utf8_find_next_char (p, NULL);
+ g_assert (q == str + 3);
+ q = g_utf8_find_next_char (q, NULL);
+ g_assert (q == str + 7);
+
+ q = g_utf8_find_next_char (p, str + 6);
+ g_assert (q == str + 3);
+ q = g_utf8_find_next_char (q, str + 6);
+ g_assert (q == NULL);
}
int main (int argc, char *argv[])
@@ -109,7 +132,7 @@ int main (int argc, char *argv[])
g_test_add_data_func ("/utf8/offsets", longline, test_utf8);
g_test_add_func ("/utf8/lengths", test_length);
- g_test_add_func ("/utf8/reverse", test_misc);
+ g_test_add_func ("/utf8/find", test_find);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]