test-fts-icu.c revision 5ae97456417a137a85c236a3db32f51fb592e474
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015 Dovecot authors, see the included COPYING file */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschstatic void test_fts_icu_utf8_to_utf16_ascii_resize(void)
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch buffer_t *dest = buffer_create_dynamic(pool_datastack_create(), 5);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch test_begin("fts_icu_utf8_to_utf16 ascii resize");
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* dynamic buffers reserve +1 for str_c()'s NUL, so 5 -> 4 */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschstatic void test_fts_icu_utf8_to_utf16_32bit_resize(void)
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Bosch unsigned int i;
7ebcb054e0d3cc4be54038cbf763ec4189d9725bStephan Bosch test_begin("fts_icu_utf8_to_utf16 32bit resize");
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch dest = buffer_create_dynamic(pool_datastack_create(), i);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch fts_icu_utf8_to_utf16(dest, "\xF0\x90\x90\x80"); /* 0x10400 */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch unsigned int i;
7384b4e78eaab44693c985192276e31322155e32Stephan Boschstatic void test_fts_icu_utf16_to_utf8_resize(void)
6a90041707f1290c8970a3bacb0f8f928aeaaba6Stephan Bosch unsigned int i;
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch test_assert(strcmp(str_c(dest), UNICODE_REPLACEMENT_CHAR_UTF8) == 0);
6a90041707f1290c8970a3bacb0f8f928aeaaba6Stephan Boschstatic UTransliterator *get_translit(const char *id)
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch id_utf16 = buffer_create_dynamic(pool_datastack_create(), 16);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch translit = utrans_openU(id_utf16->data, id_utf16->used/sizeof(UChar),
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch buffer_t *dest = buffer_create_dynamic(pool_datastack_create(), 64);
1ec26e0b70ac7f8a4e3dfbc59aa77f572651d5aeStephan Bosch unsigned int i;
d08e49550aa890e71a5f10b7de43347ec44473acTimo Sirainenstatic void test_fts_icu_translate_resize(void)
d08e49550aa890e71a5f10b7de43347ec44473acTimo Sirainen unsigned int i;
d08e49550aa890e71a5f10b7de43347ec44473acTimo Sirainen test_begin("fts_icu_translate_resize resize");
d08e49550aa890e71a5f10b7de43347ec44473acTimo Sirainen src_utf16 = buffer_create_dynamic(pool_datastack_create(), 16);
d08e49550aa890e71a5f10b7de43347ec44473acTimo Sirainen dest = buffer_create_dynamic(pool_datastack_create(), i);
d08e49550aa890e71a5f10b7de43347ec44473acTimo Sirainen test_assert(fts_icu_translate(dest, src_utf16->data,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch static void (*test_functions[])(void) = {