+ "zWÖlf ärgerliche Würste rollen ÜBer die StRAße",
+ "Zwölf Ärgerliche Würste Rollen Über Die Straße"));
+
+}
+
+
+// DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8
+
+int test_icu_sortmap(const char * locale, int src_list_len,
+ const char ** src_list, const char ** chk_list)
+{
+ int success = 1;
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ struct icu_buf_utf8 * buf8 = icu_buf_utf8_create(0);
+ struct icu_buf_utf16 * buf16 = icu_buf_utf16_create(0);
+
+ int i;
+
+ struct icu_termmap * list[src_list_len];
+
+ UCollator *coll = ucol_open(locale, &status);
+ icu_check_status(status);
+
+ if(U_FAILURE(status))
+ return 0;
+
+ // assigning display terms and sort keys using buf 8 and buf16
+ for( i = 0; i < src_list_len; i++)
+ {
+
+ list[i] = (struct icu_termmap *) malloc(sizeof(struct icu_termmap));
+
+ // copy display term
+ strcpy(list[i]->disp_term, src_list[i]);
+
+ // transforming to UTF16
+ icu_utf16_from_utf8_cstr(buf16, list[i]->disp_term, &status);
+ icu_check_status(status);
+
+ // computing sortkeys
+ icu_sortkey8_from_utf16(coll, buf8, buf16, &status);
+ icu_check_status(status);
+
+ // assigning sortkeys
+ memcpy(list[i]->sort_key, buf8->utf8, buf8->utf8_len);
+ //strncpy(list[i]->sort_key, buf8->utf8, buf8->utf8_len);
+ //strcpy((char *) list[i]->sort_key, (const char *) buf8->utf8);
+ }
+
+
+ // do the sorting
+ qsort(list, src_list_len,
+ sizeof(struct icu_termmap *), icu_termmap_cmp);
+
+ // checking correct sorting
+ for (i = 0; i < src_list_len; i++){
+ if (0 != strcmp(list[i]->disp_term, chk_list[i])){
+ success = 0;
+ }
+ }
+
+ if(!success){
+ printf("\nERROR\n");
+ printf("Input str: '%s' : ", locale);
+ for (i = 0; i < src_list_len; i++) {
+ printf(" '%s'", list[i]->disp_term);
+ }
+ printf("\n");
+ printf("ICU sort: '%s' : ", locale);
+ for (i = 0; i < src_list_len; i++) {
+ printf(" '%s'", list[i]->disp_term);
+ //printf("(%d|%d)", list[i]->sort_key[0],list[i]->sort_key[1]);
+ }
+ printf("\n");
+ printf("Expected: '%s' : ", locale);
+ for (i = 0; i < src_list_len; i++) {
+ printf(" '%s'", chk_list[i]);
+ }
+ printf("\n");
+ }
+
+
+
+ for( i = 0; i < src_list_len; i++)
+ free(list[i]);
+
+
+ ucol_close(coll);
+
+ icu_buf_utf8_destroy(buf8);
+ icu_buf_utf16_destroy(buf16);
+
+ return success;
+}
+
+
+// DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8
+
+void test_icu_I18N_sortmap(int argc, char **argv)
+{
+
+ // sucessful tests
+ size_t en_1_len = 6;
+ const char * en_1_src[6] = {"z", "K", "a", "A", "Z", "k"};
+ const char * en_1_cck[6] = {"a", "A", "k", "K", "z", "Z"};
+ YAZ_CHECK(test_icu_sortmap("en", en_1_len, en_1_src, en_1_cck));
+ YAZ_CHECK(test_icu_sortmap("en_AU", en_1_len, en_1_src, en_1_cck));
+ YAZ_CHECK(test_icu_sortmap("en_CA", en_1_len, en_1_src, en_1_cck));
+ YAZ_CHECK(test_icu_sortmap("en_GB", en_1_len, en_1_src, en_1_cck));
+ YAZ_CHECK(test_icu_sortmap("en_US", en_1_len, en_1_src, en_1_cck));
+
+ // sucessful tests
+ size_t da_1_len = 6;
+ const char * da_1_src[6] = {"z", "å", "o", "æ", "a", "ø"};
+ const char * da_1_cck[6] = {"a", "o", "z", "æ", "ø", "å"};
+ YAZ_CHECK(test_icu_sortmap("da", da_1_len, da_1_src, da_1_cck));
+ YAZ_CHECK(test_icu_sortmap("da_DK", da_1_len, da_1_src, da_1_cck));
+
+ // sucessful tests
+ size_t de_1_len = 9;
+ const char * de_1_src[9] = {"u", "ä", "o", "t", "s", "ß", "ü", "ö", "a"};
+ const char * de_1_cck[9] = {"a","ä", "o", "ö", "s", "ß", "t", "u", "ü"};
+ YAZ_CHECK(test_icu_sortmap("de", de_1_len, de_1_src, de_1_cck));
+ YAZ_CHECK(test_icu_sortmap("de_AT", de_1_len, de_1_src, de_1_cck));
+ YAZ_CHECK(test_icu_sortmap("de_DE", de_1_len, de_1_src, de_1_cck));
+
+}