[evolution-data-server/openismus-work-3-8: 54/118] e-collator-test: Add special case tests for Chinese sorting.



commit c7ec6049f89c6865200020f30e9c330663f432dc
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Sat Jun 8 21:06:30 2013 +0900

    e-collator-test: Add special case tests for Chinese sorting.
    
    Check that chinese words are sorted in the same buckets as
    Latin charachter names in an A-Z alphabetic index.

 tests/libedataserver/e-collator-test.c |   33 ++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/tests/libedataserver/e-collator-test.c b/tests/libedataserver/e-collator-test.c
index cf28a65..70e931e 100644
--- a/tests/libedataserver/e-collator-test.c
+++ b/tests/libedataserver/e-collator-test.c
@@ -170,6 +170,35 @@ test_ja_JP (CollatorFixture *fixture,
 }
 
 static void
+test_zh_CN (CollatorFixture *fixture,
+           gconstpointer    data)
+{
+  gint n_labels, underflow, inflow, overflow;
+  const gchar *const *labels;
+
+  labels = e_collator_get_index_labels (fixture->collator,
+                                       &n_labels, &underflow, &inflow, &overflow);
+
+  g_assert_cmpint (n_labels, ==, 28);
+  g_assert_cmpint (underflow, ==, 0);
+  g_assert_cmpint (overflow, ==, 27);
+  g_assert_cmpint (inflow, ==, -1);
+
+  /* Chinese and Latin words end up in the 'D' bucket */
+  g_assert_cmpstr (labels[4], ==, "D");
+  g_assert_cmpint (e_collator_get_index (fixture->collator, "东"), ==, 4);
+  g_assert_cmpint (e_collator_get_index (fixture->collator, "david"), ==, 4);
+
+  g_assert_cmpstr (labels[10], ==, "J");
+  g_assert_cmpint (e_collator_get_index (fixture->collator, "今天"), ==, 10);
+  g_assert_cmpint (e_collator_get_index (fixture->collator, "Jeffry"), ==, 10);
+
+  g_assert_cmpstr (labels[26], ==, "Z");
+  g_assert_cmpint (e_collator_get_index (fixture->collator, "早上"), ==, 26);
+  g_assert_cmpint (e_collator_get_index (fixture->collator, "Zack"), ==, 26);
+}
+
+static void
 test_ko_KR (CollatorFixture *fixture,
            gconstpointer    data)
 {
@@ -246,6 +275,10 @@ main (gint argc,
                collator_test_setup, test_ja_JP, collator_test_teardown);
 
        g_test_add (
+               "/ECollator/zh_CN", CollatorFixture, "zh_CN.UTF-8",
+               collator_test_setup, test_zh_CN, collator_test_teardown);
+
+       g_test_add (
                "/ECollator/ko_KR", CollatorFixture, "ko_KR.UTF-8",
                collator_test_setup, test_ko_KR, collator_test_teardown);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]