diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-09-08 22:49:29 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-09-08 22:49:29 +0900 |
commit | 3b116dcddafed5f018198863aac3cd81d3c7c7e2 (patch) | |
tree | 36e082d5a3d13e03ecb9c18d57834cb3bfa13659 /test/api | |
parent | b08254dad51328fed58b3c0999a1eb7a25f53efc (diff) | |
download | harfbuzz-tizen_2.3.1.tar.gz harfbuzz-tizen_2.3.1.tar.bz2 harfbuzz-tizen_2.3.1.zip |
tizen 2.3.1 releasetizen_2.4_mobile_releasetizen_2.3.1_releasesubmit/tizen_2.4/20151028.064956submit/tizen_2.3.1/20150915.083017accepted/tizen/2.4/mobile/20151029.031010tizen_2.4tizen_2.3.1accepted/tizen_2.4_mobile
Diffstat (limited to 'test/api')
-rw-r--r-- | test/api/.valgrind-suppressions | 0 | ||||
-rw-r--r-- | test/api/Makefile.am | 23 | ||||
-rw-r--r-- | test/api/hb-test.h | 2 | ||||
-rw-r--r-- | test/api/test-blob.c | 62 | ||||
-rw-r--r-- | test/api/test-buffer.c | 123 | ||||
-rw-r--r-- | test/api/test-c.c | 4 | ||||
-rw-r--r-- | test/api/test-font.c | 1 | ||||
-rw-r--r-- | test/api/test-object.c | 14 | ||||
-rw-r--r-- | test/api/test-ot-tag.c | 11 | ||||
-rw-r--r-- | test/api/test-set.c | 250 | ||||
-rw-r--r-- | test/api/test-shape-complex.c | 1159 | ||||
-rw-r--r-- | test/api/test-unicode.c | 52 | ||||
-rw-r--r-- | test/api/test-version.c | 29 |
13 files changed, 526 insertions, 1204 deletions
diff --git a/test/api/.valgrind-suppressions b/test/api/.valgrind-suppressions new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/api/.valgrind-suppressions diff --git a/test/api/Makefile.am b/test/api/Makefile.am index e6c0c01..4ff14fa 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -7,8 +7,8 @@ DISTCLEANFILES = MAINTAINERCLEANFILES = if HAVE_GLIB -AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ -I$(top_builddir)/src/ $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) -LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS) $(GTHREAD_LIBS) +AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ -I$(top_builddir)/src/ $(GLIB_CFLAGS) +LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS) EXTRA_DIST += hb-test.h @@ -21,11 +21,23 @@ TEST_PROGS = \ test-common \ test-font \ test-object \ + test-set \ test-shape \ test-unicode \ test-version \ $(NULL) +test_unicode_CPPFLAGS = $(AM_CPPFLAGS) +test_unicode_LDADD = $(LDADD) +if HAVE_GLIB +test_unicode_CPPFLAGS += $(GLIB_CFLAGS) +endif +if HAVE_ICU +test_unicode_CPPFLAGS += $(ICU_CFLAGS) +test_unicode_LDADD += $(top_builddir)/src/libharfbuzz-icu.la +endif + + if HAVE_OT TEST_PROGS += \ test-ot-tag \ @@ -49,7 +61,6 @@ test_c_CPPFLAGS += $(FREETYPE_CFLAGS) test_cplusplus_CPPFLAGS += $(FREETYPE_CFLAGS) endif - # Default test running environment TESTS = $(TEST_PROGS) TESTS_ENVIRONMENT = \ @@ -58,7 +69,7 @@ TESTS_ENVIRONMENT = \ G_DEBUG=gc-friendly \ G_SLICE=always-malloc \ srcdir=$(srcdir) \ - $(ENV) + $(NULL) # check-tool: Run tests under $(TOOL) @@ -86,8 +97,8 @@ VALGRIND_FLAGS = \ $(EXTRA_VALGRIND_FLAGS) # Can't do for now: --show-reachable=yes CLEANFILES += log-valgrind.txt -valgrind_verbose = $(valgrind_verbose_$(V)) -valgrind_verbose_ = $(valgrind_verbose_$(AM_DEFAULT_VERBOSITY)) +valgrind_verbose = $(valgrind_verbose_@AM_V@) +valgrind_verbose_ = $(valgrind_verbose_@AM_DEFAULT_V@) valgrind_verbose_0 = | \ grep '\(^[^=]\|ERROR SUMMARY\|definitely lost\|indirectly lost\)' | grep -v ': 0' # TODO: The following check does not fail if valgrind finds error. It should. diff --git a/test/api/hb-test.h b/test/api/hb-test.h index f36d53b..4d41218 100644 --- a/test/api/hb-test.h +++ b/test/api/hb-test.h @@ -33,6 +33,7 @@ #include <stdlib.h> #include <string.h> +#include <stdio.h> HB_BEGIN_DECLS @@ -75,7 +76,6 @@ srcdir (void) static inline void hb_test_init (int *argc, char ***argv) { - g_thread_init (NULL); g_test_init (argc, argv, NULL); } diff --git a/test/api/test-blob.c b/test/api/test-blob.c index 5fcb208..f671331 100644 --- a/test/api/test-blob.c +++ b/test/api/test-blob.c @@ -53,6 +53,9 @@ test_blob_empty (void) g_assert (hb_blob_is_immutable (hb_blob_get_empty ())); g_assert (hb_blob_get_empty () != NULL); g_assert (hb_blob_get_empty () == hb_blob_create (NULL, 0, HB_MEMORY_MODE_READONLY, NULL, NULL)); + g_assert (hb_blob_get_empty () == hb_blob_create ("asdf", 0, HB_MEMORY_MODE_READONLY, NULL, NULL)); + g_assert (hb_blob_get_empty () == hb_blob_create (NULL, -1, HB_MEMORY_MODE_READONLY, NULL, NULL)); + g_assert (hb_blob_get_empty () == hb_blob_create ("asdfg", -1, HB_MEMORY_MODE_READONLY, NULL, NULL)); blob = hb_blob_get_empty (); g_assert (blob == hb_blob_get_empty ()); @@ -68,7 +71,7 @@ test_blob_empty (void) g_assert_cmpint (len, ==, 0); data_writable = hb_blob_get_data_writable (blob, NULL); - g_assert (data == NULL); + g_assert (data_writable == NULL); data_writable = hb_blob_get_data_writable (blob, &len); g_assert (data_writable == NULL); @@ -262,16 +265,61 @@ static void test_blob_subblob (fixture_t *fixture, gconstpointer user_data) { hb_blob_t *b = fixture->blob; + hb_memory_mode_t mm = GPOINTER_TO_INT (user_data); + unsigned int len; + const char *data; + char *data_writable; + unsigned int i; - fixture->len -= 2; - fixture->data++; - fixture->blob = hb_blob_create_sub_blob (b, 1, fixture->len); + if (mm == HB_MEMORY_MODE_DUPLICATE) { + g_assert_cmpint (fixture->freed, ==, 1); + fixture->data = (char *) hb_blob_get_data (b, NULL); + } else { + g_assert_cmpint (fixture->freed, ==, 0); + } + fixture->blob = hb_blob_create_sub_blob (b, 1, fixture->len - 2); hb_blob_destroy (b); + b = fixture->blob; + + /* A sub-blob is always created READONLY. */ + + g_assert (b); - test_blob (fixture, user_data); + len = hb_blob_get_length (b); + g_assert_cmpint (len, ==, fixture->len - 2); + + data = hb_blob_get_data (b, &len); + g_assert_cmpint (len, ==, fixture->len - 2); + g_assert (data == fixture->data + 1); - fixture->data--; - fixture->len += 2; + data_writable = hb_blob_get_data_writable (b, &len); + g_assert_cmpint (len, ==, fixture->len - 2); + g_assert (data_writable); + if (mm == HB_MEMORY_MODE_READONLY) + g_assert (0 == memcmp (data_writable, fixture->data + 1, fixture->len - 2)); + g_assert (data_writable != data); + g_assert_cmpint (fixture->freed, ==, 1); + + data = hb_blob_get_data (b, &len); + g_assert_cmpint (len, ==, fixture->len - 2); + g_assert (data == data_writable); + + memset (data_writable, 0, fixture->len - 2); + + /* Now, make it immutable and watch get_data_writable() fail */ + + g_assert (!hb_blob_is_immutable (b)); + hb_blob_make_immutable (b); + g_assert (hb_blob_is_immutable (b)); + + data_writable = hb_blob_get_data_writable (b, &len); + g_assert (!data_writable); + g_assert_cmpint (len, ==, 0); + + data = hb_blob_get_data (b, &len); + g_assert_cmpint (len, ==, fixture->len - 2); + for (i = 0; i < len; i++) + g_assert ('\0' == data[i]); } diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c index ab818d0..17607f1 100644 --- a/test/api/test-buffer.c +++ b/test/api/test-buffer.c @@ -71,7 +71,7 @@ fixture_init (fixture_t *fixture, gconstpointer user_data) case BUFFER_ONE_BY_ONE: for (i = 1; i < G_N_ELEMENTS (utf32) - 1; i++) - hb_buffer_add (b, utf32[i], 1, i); + hb_buffer_add (b, utf32[i], i); break; case BUFFER_UTF32: @@ -127,8 +127,44 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) hb_buffer_set_language (b, hb_language_from_string ("fa", -1)); g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1)); + hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT); + g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT); - /* test reset clears properties */ + hb_buffer_set_replacement_codepoint (b, (unsigned int) -1); + g_assert (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1); + + + /* test clear_contents clears all these properties: */ + + hb_buffer_clear_contents (b); + + g_assert (hb_buffer_get_unicode_funcs (b) == ufuncs); + g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID); + g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID); + g_assert (hb_buffer_get_language (b) == NULL); + + /* but not these: */ + + g_assert (hb_buffer_get_flags (b) != HB_BUFFER_FLAGS_DEFAULT); + g_assert (hb_buffer_get_replacement_codepoint (b) != HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT); + + + /* test reset clears all properties */ + + hb_buffer_set_direction (b, HB_DIRECTION_RTL); + g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_RTL); + + hb_buffer_set_script (b, HB_SCRIPT_ARABIC); + g_assert (hb_buffer_get_script (b) == HB_SCRIPT_ARABIC); + + hb_buffer_set_language (b, hb_language_from_string ("fa", -1)); + g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1)); + + hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT); + g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT); + + hb_buffer_set_replacement_codepoint (b, (unsigned int) -1); + g_assert (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1); hb_buffer_reset (b); @@ -136,6 +172,8 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data) g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID); g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID); g_assert (hb_buffer_get_language (b) == NULL); + g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT); + g_assert (hb_buffer_get_replacement_codepoint (b) == HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT); } static void @@ -152,7 +190,7 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data) } len = hb_buffer_get_length (b); - glyphs = hb_buffer_get_glyph_infos (b, NULL); /* test NULL */ + hb_buffer_get_glyph_infos (b, NULL); /* test NULL */ glyphs = hb_buffer_get_glyph_infos (b, &len2); g_assert_cmpint (len, ==, len2); g_assert_cmpint (len, ==, 5); @@ -264,7 +302,7 @@ test_buffer_positions (fixture_t *fixture, gconstpointer user_data) /* Without shaping, positions should all be zero */ len = hb_buffer_get_length (b); - positions = hb_buffer_get_glyph_positions (b, NULL); /* test NULL */ + hb_buffer_get_glyph_positions (b, NULL); /* test NULL */ positions = hb_buffer_get_glyph_positions (b, &len2); g_assert_cmpint (len, ==, len2); for (i = 0; i < len; i++) { @@ -345,6 +383,7 @@ test_buffer_utf8_conversion (void) unsigned int bytes, chars, i, j, len; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf8_conversion_tests); i++) { @@ -359,7 +398,7 @@ test_buffer_utf8_conversion (void) for (chars = 0; test->codepoints[chars]; chars++) ; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf8 (b, test->utf8, bytes, 1, bytes - 2); glyphs = hb_buffer_get_glyph_infos (b, &len); @@ -420,11 +459,15 @@ static const utf8_validity_test_t utf8_validity_tests[] = { { "\x7f", -1, 1, TRUE }, { "\xdf\xbf", -1, 2, TRUE }, { "\xef\xbf\xbf", -1, 0, TRUE }, - { "\xf7\xbf\xbf\xbf", -1, 0, TRUE }, + { "\xf4\x8f\xbf\xbf", -1, 0, TRUE }, + { "\xf4\x90\xbf\xbf", -1, 0, FALSE }, + { "\xf7\xbf\xbf\xbf", -1, 0, FALSE }, { "\xfb\xbf\xbf\xbf\xbf", -1, 0, FALSE }, { "\xfd\xbf\xbf\xbf\xbf\xbf", -1, 0, FALSE }, /* other boundary conditions */ { "\xed\x9f\xbf", -1, 3, TRUE }, + { "\xed\xa0\x80", -1, 0, FALSE }, + { "\xed\xbf\xbf", -1, 0, FALSE }, { "\xee\x80\x80", -1, 3, TRUE }, { "\xef\xbf\xbd", -1, 3, TRUE }, { "\xf4\x8f\xbf\xbf", -1, 0, TRUE }, @@ -581,8 +624,6 @@ static const utf8_validity_test_t utf8_validity_tests[] = { /* impossible bytes */ { "\x20\xfe\x20", -1, 1, FALSE }, { "\x20\xff\x20", -1, 1, FALSE }, -#if 0 - /* XXX fix these, or document that we don't detect them? */ /* overlong sequences */ { "\x20\xc0\xaf\x20", -1, 1, FALSE }, { "\x20\xe0\x80\xaf\x20", -1, 1, FALSE }, @@ -615,6 +656,7 @@ static const utf8_validity_test_t utf8_validity_tests[] = { { "\x20\xed\xae\x80\xed\xbf\xbf\x20", -1, 1, FALSE }, { "\x20\xed\xaf\xbf\xed\xb0\x80\x20", -1, 1, FALSE }, { "\x20\xed\xaf\xbf\xed\xbf\xbf\x20", -1, 1, FALSE }, +#if 0 /* We don't consider U+FFFE / U+FFFF and similar invalid. */ { "\x20\xef\xbf\xbe\x20", -1, 1, FALSE }, { "\x20\xef\xbf\xbf\x20", -1, 1, FALSE }, #endif @@ -628,6 +670,7 @@ test_buffer_utf8_validity (void) unsigned int i; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf8_validity_tests); i++) { @@ -646,7 +689,7 @@ test_buffer_utf8_validity (void) else segment_bytes = test->max_len; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf8 (b, test->utf8, text_bytes, 0, segment_bytes); glyphs = hb_buffer_get_glyph_infos (b, &len); @@ -675,7 +718,8 @@ static const utf16_conversion_test_t utf16_conversion_tests[] = { {{0x41, 0xD800, 0xDF02}, {-1}}, {{0x41, 0x61, 0xD800, 0xDF02}, {0x61, -1}}, {{0x41, 0xD800, 0x61, 0xDF02}, {-1, 0x61}}, - {{0x41, 0x61}, {}} + {{0x41, 0xDF00, 0x61}, {-1}}, + {{0x41, 0x61}, {0}} }; static void @@ -685,6 +729,7 @@ test_buffer_utf16_conversion (void) unsigned int i; b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf16_conversion_tests); i++) { @@ -699,7 +744,7 @@ test_buffer_utf16_conversion (void) for (chars = 0; test->codepoints[chars]; chars++) ; - hb_buffer_reset (b); + hb_buffer_clear_contents (b); hb_buffer_add_utf16 (b, test->utf16, u_len, 1, u_len - 2); glyphs = hb_buffer_get_glyph_infos (b, &len); @@ -711,6 +756,61 @@ test_buffer_utf16_conversion (void) hb_buffer_destroy (b); } + +typedef struct { + const uint32_t utf32[8]; + const uint32_t codepoints[8]; +} utf32_conversion_test_t; + +/* note: we skip the first and last item from utf32 when adding to buffer */ +static const utf32_conversion_test_t utf32_conversion_tests[] = { + {{0x41, 0x004D, 0x0430, 0x4E8C, 0xD800, 0xDF02, 0x61} , {0x004D, 0x0430, 0x4E8C, -3, -3}}, + {{0x41, 0x004D, 0x0430, 0x4E8C, 0x10302, 0x61} , {0x004D, 0x0430, 0x4E8C, 0x10302}}, + {{0x41, 0xD800, 0xDF02, 0x61}, {-3, -3}}, + {{0x41, 0xD800, 0xDF02}, {-3}}, + {{0x41, 0x61, 0xD800, 0xDF02}, {0x61, -3}}, + {{0x41, 0xD800, 0x61, 0xDF02}, {-3, 0x61}}, + {{0x41, 0xDF00, 0x61}, {-3}}, + {{0x41, 0x10FFFF, 0x61}, {0x10FFFF}}, + {{0x41, 0x110000, 0x61}, {-3}}, + {{0x41, 0x61}, {0}} +}; + +static void +test_buffer_utf32_conversion (void) +{ + hb_buffer_t *b; + unsigned int i; + + b = hb_buffer_create (); + hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -3); + + for (i = 0; i < G_N_ELEMENTS (utf32_conversion_tests); i++) + { + const utf32_conversion_test_t *test = &utf32_conversion_tests[i]; + unsigned int u_len, chars, j, len; + hb_glyph_info_t *glyphs; + + g_test_message ("UTF-32 test #%d", i); + + for (u_len = 0; test->utf32[u_len]; u_len++) + ; + for (chars = 0; test->codepoints[chars]; chars++) + ; + + hb_buffer_clear_contents (b); + hb_buffer_add_utf32 (b, test->utf32, u_len, 1, u_len - 2); + + glyphs = hb_buffer_get_glyph_infos (b, &len); + g_assert_cmpint (len, ==, chars); + for (j = 0; j < chars; j++) + g_assert_cmphex (glyphs[j].codepoint, ==, test->codepoints[j]); + } + + hb_buffer_destroy (b); +} + + static void test_empty (hb_buffer_t *b) { @@ -777,6 +877,7 @@ main (int argc, char **argv) hb_test_add (test_buffer_utf8_conversion); hb_test_add (test_buffer_utf8_validity); hb_test_add (test_buffer_utf16_conversion); + hb_test_add (test_buffer_utf32_conversion); hb_test_add (test_buffer_empty); return hb_test_run(); diff --git a/test/api/test-c.c b/test/api/test-c.c index 25a38e5..6e8602f 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -51,6 +51,10 @@ #include <hb-uniscribe.h> #endif +#ifdef HAVE_CORETEXT +#include <hb-coretext.h> +#endif + int main (int argc, char **argv) { diff --git a/test/api/test-font.c b/test/api/test-font.c index 40540c4..6b6a503 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c @@ -136,7 +136,6 @@ _test_font_nil_funcs (hb_font_t *font) g_assert (!hb_font_get_glyph (font, 17, 2, &glyph)); g_assert_cmpint (glyph, ==, 0); - x = 13; x = hb_font_get_glyph_h_kerning (font, 17, 19); g_assert_cmpint (x, ==, 0); } diff --git a/test/api/test-object.c b/test/api/test-object.c index 66e8d33..3afe6ae 100644 --- a/test/api/test-object.c +++ b/test/api/test-object.c @@ -53,6 +53,17 @@ create_buffer_inert (void) } static void * +create_set (void) +{ + return hb_set_create (); +} +static void * +create_set_inert (void) +{ + return NULL; +} + +static void * create_face (void) { hb_blob_t *blob = (hb_blob_t *) create_blob (); @@ -154,6 +165,7 @@ typedef struct { static const object_t objects[] = { OBJECT_WITHOUT_IMMUTABILITY (buffer), + OBJECT_WITHOUT_IMMUTABILITY (set), OBJECT_WITH_IMMUTABILITY (blob), OBJECT_WITH_IMMUTABILITY (face), OBJECT_WITH_IMMUTABILITY (font), @@ -219,7 +231,7 @@ test_object (void) for (i = 0; i < G_N_ELEMENTS (objects); i++) { const object_t *o = &objects[i]; void *obj; - hb_user_data_key_t key[2]; + hb_user_data_key_t key[1001]; { unsigned int j; diff --git a/test/api/test-ot-tag.c b/test/api/test-ot-tag.c index 81b6678..b667c7d 100644 --- a/test/api/test-ot-tag.c +++ b/test/api/test-ot-tag.c @@ -132,6 +132,7 @@ test_ot_tag_script_indic (void) test_indic_tags ("ory2", "orya", HB_SCRIPT_ORIYA); test_indic_tags ("tml2", "taml", HB_SCRIPT_TAMIL); test_indic_tags ("tel2", "telu", HB_SCRIPT_TELUGU); + test_indic_tags ("mym2", "mymr", HB_SCRIPT_MYANMAR); } @@ -194,17 +195,21 @@ test_ot_tag_language (void) test_language_two_way ("ZHH", "zh-hk"); /* Chinese (Hong Kong) */ + test_tag_from_language ("ZHS", "zh"); /* Chinese */ test_tag_from_language ("ZHS", "zh-cn"); /* Chinese (China) */ test_tag_from_language ("ZHS", "zh-sg"); /* Chinese (Singapore) */ test_tag_from_language ("ZHT", "zh-mo"); /* Chinese (Macao) */ test_tag_from_language ("ZHT", "zh-tw"); /* Chinese (Taiwan) */ + test_tag_from_language ("ZHS", "zh-Hans"); /* Chinese (Simplified) */ + test_tag_from_language ("ZHT", "zh-Hant"); /* Chinese (Traditional) */ + test_tag_from_language ("ZHS", "zh-xx"); /* Chinese (Other) */ test_tag_from_language ("ZHS", "zh"); /* Chinese */ test_tag_from_language ("ZHS", "zh-xx"); - test_tag_to_language ("ZHS", "zh-x-hbotzhs"); - test_tag_to_language ("ZHT", "zh-x-hbotzht"); - test_tag_to_language ("ZHP", "zh-x-hbotzhp"); + test_tag_to_language ("ZHS", "zh-Hans"); + test_tag_to_language ("ZHT", "zh-Hant"); + test_tag_to_language ("ZHP", "x-hbotzhp"); test_language_two_way ("ABC", "x-hbotabc"); test_tag_from_language ("ABC", "asdf-asdf-wer-x-hbotabc-zxc"); diff --git a/test/api/test-set.c b/test/api/test-set.c new file mode 100644 index 0000000..9634951 --- /dev/null +++ b/test/api/test-set.c @@ -0,0 +1,250 @@ +/* + * Copyright © 2013 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-test.h" + +/* Unit tests for hb-set.h */ + + +static void +test_empty (hb_set_t *s) +{ + hb_codepoint_t next = HB_SET_VALUE_INVALID; + g_assert_cmpint (hb_set_get_population (s), ==, 0); + g_assert_cmpint (hb_set_get_min (s), ==, HB_SET_VALUE_INVALID); + g_assert_cmpint (hb_set_get_max (s), ==, HB_SET_VALUE_INVALID); + g_assert (!hb_set_has (s, 13)); + g_assert (!hb_set_next (s, &next)); + g_assert_cmpint (next, ==, HB_SET_VALUE_INVALID); + g_assert (hb_set_is_empty (s)); +} + +static void +test_not_empty (hb_set_t *s) +{ + hb_codepoint_t next = HB_SET_VALUE_INVALID; + g_assert_cmpint (hb_set_get_population (s), !=, 0); + g_assert_cmpint (hb_set_get_min (s), !=, HB_SET_VALUE_INVALID); + g_assert_cmpint (hb_set_get_max (s), !=, HB_SET_VALUE_INVALID); + g_assert (hb_set_next (s, &next)); + g_assert_cmpint (next, !=, HB_SET_VALUE_INVALID); +} + +static void +test_set_basic (void) +{ + hb_set_t *s = hb_set_create (); + + test_empty (s); + hb_set_add (s, 13); + test_not_empty (s); + + hb_set_clear (s); + test_empty (s); + + hb_set_add (s, 33000); + test_not_empty (s); + hb_set_clear (s); + + hb_set_add_range (s, 10, 29); + test_not_empty (s); + g_assert (hb_set_has (s, 13)); + g_assert_cmpint (hb_set_get_population (s), ==, 20); + g_assert_cmpint (hb_set_get_min (s), ==, 10); + g_assert_cmpint (hb_set_get_max (s), ==, 29); + + hb_set_invert (s); + test_not_empty (s); + g_assert (!hb_set_has (s, 13)); + g_assert_cmpint (hb_set_get_min (s), ==, 0); + + hb_set_invert (s); + test_not_empty (s); + g_assert (hb_set_has (s, 13)); + g_assert_cmpint (hb_set_get_population (s), ==, 20); + g_assert_cmpint (hb_set_get_min (s), ==, 10); + g_assert_cmpint (hb_set_get_max (s), ==, 29); + + hb_set_del_range (s, 10, 18); + test_not_empty (s); + g_assert (!hb_set_has (s, 13)); + + hb_set_destroy (s); +} + +static void +test_set_algebra (void) +{ + hb_set_t *s = hb_set_create (); + hb_set_t *o = hb_set_create (); + + hb_set_add (o, 13); + hb_set_add (o, 19); + + test_empty (s); + g_assert (!hb_set_is_equal (s, o)); + hb_set_set (s, o); + g_assert (hb_set_is_equal (s, o)); + test_not_empty (s); + g_assert_cmpint (hb_set_get_population (s), ==, 2); + + hb_set_clear (s); + test_empty (s); + hb_set_add (s, 10); + g_assert_cmpint (hb_set_get_population (s), ==, 1); + hb_set_union (s, o); + g_assert_cmpint (hb_set_get_population (s), ==, 3); + g_assert (hb_set_has (s, 10)); + g_assert (hb_set_has (s, 13)); + + hb_set_clear (s); + test_empty (s); + hb_set_add_range (s, 10, 17); + g_assert (!hb_set_is_equal (s, o)); + hb_set_intersect (s, o); + g_assert (!hb_set_is_equal (s, o)); + test_not_empty (s); + g_assert_cmpint (hb_set_get_population (s), ==, 1); + g_assert (!hb_set_has (s, 10)); + g_assert (hb_set_has (s, 13)); + + hb_set_clear (s); + test_empty (s); + hb_set_add_range (s, 10, 17); + g_assert (!hb_set_is_equal (s, o)); + hb_set_subtract (s, o); + g_assert (!hb_set_is_equal (s, o)); + test_not_empty (s); + g_assert_cmpint (hb_set_get_population (s), ==, 7); + g_assert (hb_set_has (s, 12)); + g_assert (!hb_set_has (s, 13)); + g_assert (!hb_set_has (s, 19)); + + hb_set_clear (s); + test_empty (s); + hb_set_add_range (s, 10, 17); + g_assert (!hb_set_is_equal (s, o)); + hb_set_symmetric_difference (s, o); + g_assert (!hb_set_is_equal (s, o)); + test_not_empty (s); + g_assert_cmpint (hb_set_get_population (s), ==, 8); + g_assert (hb_set_has (s, 12)); + g_assert (!hb_set_has (s, 13)); + g_assert (hb_set_has (s, 19)); + + hb_set_destroy (s); +} + +static void +test_set_iter (void) +{ + hb_codepoint_t next, first, last; + hb_set_t *s = hb_set_create (); + + hb_set_add (s, 13); + hb_set_add_range (s, 6, 6); + hb_set_add_range (s, 10, 15); + hb_set_add (s, 20005); + + test_not_empty (s); + + next = HB_SET_VALUE_INVALID; + g_assert (hb_set_next (s, &next)); + g_assert_cmpint (next, ==, 6); + g_assert (hb_set_next (s, &next)); + g_assert_cmpint (next, ==, 10); + g_assert (hb_set_next (s, &next)); + g_assert (hb_set_next (s, &next)); + g_assert (hb_set_next (s, &next)); + g_assert_cmpint (next, ==, 13); + g_assert (hb_set_next (s, &next)); + g_assert (hb_set_next (s, &next)); + g_assert_cmpint (next, ==, 15); + g_assert (hb_set_next (s, &next)); + g_assert_cmpint (next, ==, 20005); + g_assert (!hb_set_next (s, &next)); + g_assert_cmpint (next, ==, HB_SET_VALUE_INVALID); + + first = last = HB_SET_VALUE_INVALID; + g_assert (hb_set_next_range (s, &first, &last)); + g_assert_cmpint (first, ==, 6); + g_assert_cmpint (last, ==, 6); + g_assert (hb_set_next_range (s, &first, &last)); + g_assert_cmpint (first, ==, 10); + g_assert_cmpint (last, ==, 15); + g_assert (hb_set_next_range (s, &first, &last)); + g_assert_cmpint (first, ==, 20005); + g_assert_cmpint (last, ==, 20005); + g_assert (!hb_set_next_range (s, &first, &last)); + g_assert_cmpint (first, ==, HB_SET_VALUE_INVALID); + g_assert_cmpint (last, ==, HB_SET_VALUE_INVALID); + + hb_set_destroy (s); +} + +static void +test_set_empty (void) +{ + hb_set_t *b = hb_set_get_empty (); + + g_assert (hb_set_get_empty ()); + g_assert (hb_set_get_empty () == b); + + g_assert (!hb_set_allocation_successful (b)); + + test_empty (b); + + hb_set_add (b, 13); + + test_empty (b); + + hb_set_invert (b); + + test_empty (b); + + g_assert (!hb_set_allocation_successful (b)); + + hb_set_clear (b); + + test_empty (b); + + g_assert (!hb_set_allocation_successful (b)); + + hb_set_destroy (b); +} + +int +main (int argc, char **argv) +{ + hb_test_init (&argc, &argv); + + hb_test_add (test_set_basic); + hb_test_add (test_set_algebra); + hb_test_add (test_set_iter); + hb_test_add (test_set_empty); + + return hb_test_run(); +} diff --git a/test/api/test-shape-complex.c b/test/api/test-shape-complex.c deleted file mode 100644 index 1963b5e..0000000 --- a/test/api/test-shape-complex.c +++ /dev/null @@ -1,1159 +0,0 @@ -/* - * Copyright © 2011 Google, Inc. - * Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies) - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-test.h" - -/* Unit tests for complex text shaping */ - -/* - * This test provides a framework to test aspects of hb_shape() that are - * font-dependent. Please add tests for any feature that fits that - * description. - */ - -#include <hb-ft.h> - -typedef struct -{ - const char *font_file; - unsigned int face_index; - /* TODO add min/max face version */ -} font_data_t; - -static char * -get_font_file (const font_data_t *font_data) -{ - return g_strdup_printf ("%s/fonts/%s", srcdir (), font_data->font_file); -} - - -typedef struct -{ - char comments[64]; - hb_codepoint_t characters[16]; - hb_codepoint_t glyphs[16]; -} test_data_t; - -typedef struct -{ - const font_data_t font_data; - const test_data_t test_datas[]; -} test_set_t; - -typedef struct -{ - const font_data_t *font_data; - const test_data_t *test_data; -} test_t; - - -static const test_set_t tests_devanagari1 = { - {"raghu.ttf", 0}, - { - { "Ka", - { 0x0915, 0 }, - { 0x0080, 0 } - }, - { "Ka Halant", - { 0x0915, 0x094d, 0 }, - { 0x0080, 0x0051, 0 } - }, - { "Ka Halant Ka", - { 0x0915, 0x094d, 0x0915, 0 }, - { 0x00c8, 0x0080, 0 } - }, - { "Ka MatraI", - { 0x0915, 0x093f, 0 }, - { 0x01d1, 0x0080, 0 } - }, - { "Ra Halant Ka", - { 0x0930, 0x094d, 0x0915, 0 }, - { 0x0080, 0x005b, 0 } - }, - { "Ra Halant Ka MatraI", - { 0x0930, 0x094d, 0x0915, 0x093f, 0 }, - { 0x01d1, 0x0080, 0x005b, 0 } - }, - { "MatraI", - { 0x093f, 0 }, - { 0x01d4, 0x029c, 0 } - }, - { "Ka Nukta", - { 0x0915, 0x093c, 0 }, - { 0x00a4, 0 } - }, - { "Ka Halant Ra", - { 0x0915, 0x094d, 0x0930, 0 }, - { 0x0110, 0 } - }, - { "Ka Halant Ra Halant Ka", - { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 }, - { 0x0158, 0x0080, 0 } - }, - { "", - { 0x0930, 0x094d, 0x200d, 0 }, - { 0x00e2, 0 } - }, - { "", - { 0x0915, 0x094d, 0x0930, 0x094d, 0x200d, 0 }, - { 0x0158, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_devanagari2 = { - {"mangal.ttf", 0}, - { - { "Ka", - { 0x0915, 0 }, - { 0x0080, 0 } - }, - { "Ka Halant", - { 0x0915, 0x094d, 0 }, - { 0x0080, 0x0051, 0 } - }, - { "Ka Halant Ka", - { 0x0915, 0x094d, 0x0915, 0 }, - { 0x00c8, 0x0080, 0 } - }, - { "Ka MatraI", - { 0x0915, 0x093f, 0 }, - { 0x01d1, 0x0080, 0 } - }, - { "Ra Halant Ka", - { 0x0930, 0x094d, 0x0915, 0 }, - { 0x0080, 0x005b, 0 } - }, - { "Ra Halant Ka MatraI", - { 0x0930, 0x094d, 0x0915, 0x093f, 0 }, - { 0x01d1, 0x0080, 0x005b, 0 } - }, - { "MatraI", - { 0x093f, 0 }, - { 0x01d4, 0x029c, 0 } - }, - { "Ka Nukta", - { 0x0915, 0x093c, 0 }, - { 0x00a4, 0 } - }, - { "Ka Halant Ra", - { 0x0915, 0x094d, 0x0930, 0 }, - { 0x0110, 0 } - }, - { "Ka Halant Ra Halant Ka", - { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 }, - { 0x0158, 0x0080, 0 } - }, - { "", - { 0x92b, 0x94d, 0x930, 0 }, - { 0x125, 0 } - }, - { "", - { 0x92b, 0x93c, 0x94d, 0x930, 0 }, - { 0x149, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_bengali1 = { - {"AkaashNormal.ttf", 0}, - { - { "Ka", - { 0x0995, 0 }, - { 0x0151, 0 } - }, - { "Ka Halant", - { 0x0995, 0x09cd, 0 }, - { 0x0151, 0x017d, 0 } - }, - { "Ka Halant Ka", - { 0x0995, 0x09cd, 0x0995, 0 }, - { 0x019b, 0 } - }, - { "Ka MatraI", - { 0x0995, 0x09bf, 0 }, - { 0x0173, 0x0151, 0 } - }, - { "Ra Halant Ka", - { 0x09b0, 0x09cd, 0x0995, 0 }, - { 0x0151, 0x0276, 0 } - }, - { "Ra Halant Ka MatraI", - { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 }, - { 0x0173, 0x0151, 0x0276, 0 } - }, - { "Ka Nukta", - { 0x0995, 0x09bc, 0 }, - { 0x0151, 0x0171, 0 } - }, - { "Ka Halant Ra", - { 0x0995, 0x09cd, 0x09b0, 0 }, - { 0x01f4, 0 } - }, - { "Ka Halant Ra Halant Ka", - { 0x0995, 0x09cd, 0x09b0, 0x09cd, 0x0995, 0 }, - { 0x025c, 0x0276, 0x0151, 0 } - }, - { "Ya + Halant", - { 0x09af, 0x09cd, 0 }, - { 0x016a, 0x017d, 0 } - }, - { "Da Halant Ya -> Da Ya-Phala", - { 0x09a6, 0x09cd, 0x09af, 0 }, - { 0x01e5, 0 } - }, - { "A Halant Ya -> A Ya-phala", - { 0x0985, 0x09cd, 0x09af, 0 }, - { 0x0145, 0x01cf, 0 } - }, - { "Na Halant Ka", - { 0x09a8, 0x09cd, 0x0995, 0 }, - { 0x026f, 0x0151, 0 } - }, - { "Na Halant ZWNJ Ka", - { 0x09a8, 0x09cd, 0x200c, 0x0995, 0 }, - { 0x0164, 0x017d, 0x0151, 0 } - }, - { "Na Halant ZWJ Ka", - { 0x09a8, 0x09cd, 0x200d, 0x0995, 0 }, - { 0x026f, 0x0151, 0 } - }, - { "Ka Halant ZWNJ Ka", - { 0x0995, 0x09cd, 0x200c, 0x0995, 0 }, - { 0x0151, 0x017d, 0x0151, 0 } - }, - { "Ka Halant ZWJ Ka", - { 0x0995, 0x09cd, 0x200d, 0x0995, 0 }, - { 0x025c, 0x0151, 0 } - }, - { "Na Halant Ra", - { 0x09a8, 0x09cd, 0x09b0, 0 }, - { 0x0207, 0 } - }, - { "Na Halant ZWNJ Ra", - { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 }, - { 0x0164, 0x017d, 0x016b, 0 } - }, - { "Na Halant ZWJ Ra", - { 0x09a8, 0x09cd, 0x200d, 0x09b0, 0 }, - { 0x026f, 0x016b, 0 } - }, - { "Na Halant Ba", - { 0x09a8, 0x09cd, 0x09ac, 0 }, - { 0x022f, 0 } - }, - { "Na Halant ZWNJ Ba", - { 0x09a8, 0x09cd, 0x200c, 0x09ac, 0 }, - { 0x0164, 0x017d, 0x0167, 0 } - }, - { "Na Halant ZWJ Ba", - { 0x09a8, 0x09cd, 0x200d, 0x09ac, 0 }, - { 0x026f, 0x0167, 0 } - }, - { "Na Halant Dha", - { 0x09a8, 0x09cd, 0x09a7, 0 }, - { 0x01d3, 0 } - }, - { "Na Halant ZWNJ Dha", - { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 }, - { 0x0164, 0x017d, 0x0163, 0 } - }, - { "Na Halant ZWJ Dha", - { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 }, - { 0x026f, 0x0163, 0 } - }, - { "Ra Halant Ka MatraAU", - { 0x09b0, 0x09cd, 0x0995, 0x09cc, 0 }, - { 0x0179, 0x0151, 0x0276, 0x017e, 0 } - }, - { "Ra Halant Ba Halant Ba", - { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 }, - { 0x0232, 0x0276, 0 } - }, - { "", - { 0x9b0, 0x9cd, 0x995, 0x9be, 0x982, 0 }, - { 0x151, 0x276, 0x172, 0x143, 0 } - }, - { "", - { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0 }, - { 0x151, 0x276, 0x172, 0x144, 0 } - }, - /* Test decomposed two part matras */ - { "", - { 0x995, 0x9c7, 0x9be, 0 }, - { 0x179, 0x151, 0x172, 0 } - }, - { "", - { 0x995, 0x9c7, 0x9d7, 0 }, - { 0x179, 0x151, 0x17e, 0 } - }, - { "", - { 0x9b0, 0x9cd, 0x9ad, 0 }, - { 0x168, 0x276, 0 } - }, - { "", - { 0x9f0, 0x9cd, 0x9ad, 0 }, - { 0x168, 0x276, 0 } - }, - { "", - { 0x9f1, 0x9cd, 0x9ad, 0 }, - { 0x191, 0x17d, 0x168, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_bengali2 = { - {"MuktiNarrow.ttf", 0}, - { - { "Ka", - { 0x0995, 0 }, - { 0x0073, 0 } - }, - { "Ka Halant", - { 0x0995, 0x09cd, 0 }, - { 0x00b9, 0 } - }, - { "Ka Halant Ka", - { 0x0995, 0x09cd, 0x0995, 0 }, - { 0x0109, 0 } - }, - { "Ka MatraI", - { 0x0995, 0x09bf, 0 }, - { 0x0095, 0x0073, 0 } - }, - { "Ra Halant Ka", - { 0x09b0, 0x09cd, 0x0995, 0 }, - { 0x0073, 0x00e1, 0 } - }, - { "Ra Halant Ka MatraI", - { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 }, - { 0x0095, 0x0073, 0x00e1, 0 } - }, - { "MatraI", - { 0x09bf, 0 }, - { 0x0095, 0x01c8, 0 } - }, - { "Ka Nukta", - { 0x0995, 0x09bc, 0 }, - { 0x0073, 0x0093, 0 } - }, - { "Ka Halant Ra", - { 0x0995, 0x09cd, 0x09b0, 0 }, - { 0x00e5, 0 } - }, - { "Ka Halant Ra Halant Ka", - { 0x995, 0x9cd, 0x9b0, 0x9cd, 0x995, 0 }, - { 0x234, 0x24e, 0x73, 0 } - }, - { "Ya + Halant", - { 0x09af, 0x09cd, 0 }, - { 0x00d2, 0 } - }, - { "Da Halant Ya -> Da Ya-Phala", - { 0x09a6, 0x09cd, 0x09af, 0 }, - { 0x0084, 0x00e2, 0 } - }, - { "A Halant Ya -> A Ya-phala", - { 0x0985, 0x09cd, 0x09af, 0 }, - { 0x0067, 0x00e2, 0 } - }, - { "Na Halant Ka", - { 0x09a8, 0x09cd, 0x0995, 0 }, - { 0x0188, 0 } - }, - { "Na Halant ZWNJ Ka", - { 0x9a8, 0x9cd, 0x200c, 0x995, 0 }, - { 0xcc, 0x73, 0 } - }, - { "Na Halant ZWJ Ka", - { 0x9a8, 0x9cd, 0x200d, 0x995, 0 }, - { 0x247, 0x73, 0 } - }, - { "Ka Halant ZWNJ Ka", - { 0x9a8, 0x9cd, 0x200d, 0x995, 0 }, - { 0x247, 0x73, 0 } - }, - { "Ka Halant ZWJ Ka", - { 0x9a8, 0x9cd, 0x200d, 0x995, 0 }, - { 0x247, 0x73, 0 } - }, - { "Na Halant Ra", - { 0x09a8, 0x09cd, 0x09b0, 0 }, - { 0x00f8, 0 } - }, - { "Na Halant ZWNJ Ra", - { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 }, - { 0xcc, 0x8d, 0 } - }, - { "Na Halant ZWJ Ra", - { 0x9a8, 0x9cd, 0x200d, 0x9b0, 0 }, - { 0x247, 0x8d, 0 } - }, - { "Na Halant Ba", - { 0x09a8, 0x09cd, 0x09ac, 0 }, - { 0x0139, 0 } - }, - { "Na Halant ZWNJ Ba", - { 0x9a8, 0x9cd, 0x200c, 0x9ac, 0 }, - { 0xcc, 0x89, 0 } - }, - { "Na Halant ZWJ Ba", - { 0x9a8, 0x9cd, 0x200d, 0x9ac, 0 }, - { 0x247, 0x89, 0 } - }, - { "Na Halant Dha", - { 0x09a8, 0x09cd, 0x09a7, 0 }, - { 0x0145, 0 } - }, - { "Na Halant ZWNJ Dha", - { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 }, - { 0xcc, 0x85, 0 } - }, - { "Na Halant ZWJ Dha", - { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 }, - { 0x247, 0x85, 0 } - }, - { "Ra Halant Ka MatraAU", - { 0x9b0, 0x9cd, 0x995, 0x9cc, 0 }, - { 0x232, 0x73, 0xe1, 0xa0, 0 } - }, - { "Ra Halant Ba Halant Ba", - { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 }, - { 0x013b, 0x00e1, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_bengali3 = { - {"LikhanNormal.ttf", 0}, - { - { "", - { 0x09a8, 0x09cd, 0x09af, 0 }, - { 0x01ca, 0 } - }, - { "", - { 0x09b8, 0x09cd, 0x09af, 0 }, - { 0x020e, 0 } - }, - { "", - { 0x09b6, 0x09cd, 0x09af, 0 }, - { 0x01f4, 0 } - }, - { "", - { 0x09b7, 0x09cd, 0x09af, 0 }, - { 0x01fe, 0 } - }, - { "", - { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0 }, - { 0x10b, 0x167, 0 } - }, - { "", - { 0x9b0, 0x9cd, 0x9ad, 0 }, - { 0xa1, 0x167, 0 } - }, - { "", - { 0x9f0, 0x9cd, 0x9ad, 0 }, - { 0xa1, 0x167, 0 } - }, - { "", - { 0x9f1, 0x9cd, 0x9ad, 0 }, - { 0x11c, 0xa1, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_gurmukhi = { - {"lohit_pa.ttf", 0}, - { - { "", - { 0xA15, 0xA4D, 0xa39, 0 }, - { 0x3b, 0x8b, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_oriya = { - {"utkalm.ttf", 0}, - { - { "", - { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 }, - { 0x150, 0x125, 0 } - }, - { "", - { 0xb24, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 }, - { 0x151, 0x120, 0 } - }, - { "", - { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 }, - { 0x152, 0x120, 0 } - }, - { "", - { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 }, - { 0x152, 0x120, 0 } - }, - { "", - { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 }, - { 0x176, 0 } - }, - { "", - { 0xb38, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 }, - { 0x177, 0 } - }, - { "", - { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0 }, - { 0x176, 0x124, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_tamil = { - {"akruti1.ttf", 0}, - { - { "", - { 0x0b95, 0x0bc2, 0 }, - { 0x004e, 0 } - }, - { "", - { 0x0bae, 0x0bc2, 0 }, - { 0x009e, 0 } - }, - { "", - { 0x0b9a, 0x0bc2, 0 }, - { 0x0058, 0 } - }, - { "", - { 0x0b99, 0x0bc2, 0 }, - { 0x0053, 0 } - }, - { "", - { 0x0bb0, 0x0bc2, 0 }, - { 0x00a8, 0 } - }, - { "", - { 0x0ba4, 0x0bc2, 0 }, - { 0x008e, 0 } - }, - { "", - { 0x0b9f, 0x0bc2, 0 }, - { 0x0062, 0 } - }, - { "", - { 0x0b95, 0x0bc6, 0 }, - { 0x000a, 0x0031, 0 } - }, - { "", - { 0x0b95, 0x0bca, 0 }, - { 0x000a, 0x0031, 0x0007, 0 } - }, - { "", - { 0x0b95, 0x0bc6, 0x0bbe, 0 }, - { 0x000a, 0x0031, 0x007, 0 } - }, - { "", - { 0x0b95, 0x0bcd, 0x0bb7, 0 }, - { 0x0049, 0 } - }, - { "", - { 0x0b95, 0x0bcd, 0x0bb7, 0x0bca, 0 }, - { 0x000a, 0x0049, 0x007, 0 } - }, - { "", - { 0x0b95, 0x0bcd, 0x0bb7, 0x0bc6, 0x0bbe, 0 }, - { 0x000a, 0x0049, 0x007, 0 } - }, - { "", - { 0x0b9f, 0x0bbf, 0 }, - { 0x005f, 0 } - }, - { "", - { 0x0b9f, 0x0bc0, 0 }, - { 0x0060, 0 } - }, - { "", - { 0x0bb2, 0x0bc0, 0 }, - { 0x00ab, 0 } - }, - { "", - { 0x0bb2, 0x0bbf, 0 }, - { 0x00aa, 0 } - }, - { "", - { 0x0bb0, 0x0bcd, 0 }, - { 0x00a4, 0 } - }, - { "", - { 0x0bb0, 0x0bbf, 0 }, - { 0x00a5, 0 } - }, - { "", - { 0x0bb0, 0x0bc0, 0 }, - { 0x00a6, 0 } - }, - { "", - { 0x0b83, 0 }, - { 0x0025, 0 } - }, - { "", - { 0x0b83, 0x0b95, 0 }, - { 0x0025, 0x0031, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_telugu = { - {"Pothana2000.ttf", 0}, - { - { "", - { 0xc15, 0xc4d, 0 }, - { 0xbb, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc37, 0 }, - { 0x4b, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc37, 0xc4d, 0 }, - { 0xe0, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc37, 0xc4d, 0xc23, 0 }, - { 0x4b, 0x91, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc30, 0 }, - { 0x5a, 0xb2, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc30, 0xc4d, 0 }, - { 0xbb, 0xb2, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc30, 0xc4d, 0xc15, 0 }, - { 0x5a, 0xb2, 0x83, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc30, 0xc3f, 0 }, - { 0xe2, 0xb2, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc15, 0xc48, 0 }, - { 0xe6, 0xb3, 0x83, 0 } - }, - { "", - { 0xc15, 0xc4d, 0xc30, 0xc48, 0 }, - { 0xe6, 0xb3, 0x9f, 0 } - }, - { "", - { 0xc15, 0xc46, 0xc56, 0 }, - { 0xe6, 0xb3, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_kannada1 = { - {"Sampige.ttf", 0}, - { - { "", - { 0x0ca8, 0x0ccd, 0x0ca8, 0 }, - { 0x0049, 0x00ba, 0 } - }, - { "", - { 0x0ca8, 0x0ccd, 0x0ca1, 0 }, - { 0x0049, 0x00b3, 0 } - }, - { "", - { 0x0caf, 0x0cc2, 0 }, - { 0x004f, 0x005d, 0 } - }, - { "", - { 0x0ce0, 0 }, - { 0x006a, 0 } - }, - { "", - { 0x0ce6, 0x0ce7, 0x0ce8, 0 }, - { 0x006b, 0x006c, 0x006d, 0 } - }, - { "", - { 0x0cb5, 0x0ccb, 0 }, - { 0x015f, 0x0067, 0 } - }, - { "", - { 0x0cb0, 0x0ccd, 0x0cae, 0 }, - { 0x004e, 0x0082, 0 } - }, - { "", - { 0x0cb0, 0x0ccd, 0x0c95, 0 }, - { 0x0036, 0x0082, 0 } - }, - { "", - { 0x0c95, 0x0ccd, 0x0cb0, 0 }, - { 0x0036, 0x00c1, 0 } - }, - { "", - { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0 }, - { 0x0050, 0x00a7, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_kannada2 = { - {"tunga.ttf", 0}, - { - { "", - { 0x0cb7, 0x0cc6, 0 }, - { 0x00b0, 0x006c, 0 } - }, - { "", - { 0x0cb7, 0x0ccd, 0 }, - { 0x0163, 0 } - }, - { "", - { 0xc95, 0xcbf, 0xcd5, 0 }, - { 0x114, 0x73, 0 } - }, - { "", - { 0xc95, 0xcc6, 0xcd5, 0 }, - { 0x90, 0x6c, 0x73, 0 } - }, - { "", - { 0xc95, 0xcc6, 0xcd6, 0 }, - { 0x90, 0x6c, 0x74, 0 } - }, - { "", - { 0xc95, 0xcc6, 0xcc2, 0 }, - { 0x90, 0x6c, 0x69, 0 } - }, - { "", - { 0xc95, 0xcca, 0xcd5, 0 }, - { 0x90, 0x6c, 0x69, 0x73, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_malayalam1 = { - {"AkrutiMal2Normal.ttf", 0}, - { - { "", - { 0x0d15, 0x0d46, 0 }, - { 0x005e, 0x0034, 0 } - }, - { "", - { 0x0d15, 0x0d47, 0 }, - { 0x005f, 0x0034, 0 } - }, - { "", - { 0x0d15, 0x0d4b, 0 }, - { 0x005f, 0x0034, 0x0058, 0 } - }, - { "", - { 0x0d15, 0x0d48, 0 }, - { 0x0060, 0x0034, 0 } - }, - { "", - { 0x0d15, 0x0d4a, 0 }, - { 0x005e, 0x0034, 0x0058, 0 } - }, - { "", - { 0x0d30, 0x0d4d, 0x0d15, 0 }, - { 0x009e, 0x0034, 0 } - }, - { "", - { 0x0d15, 0x0d4d, 0x0d35, 0 }, - { 0x0034, 0x007a, 0 } - }, - { "", - { 0x0d15, 0x0d4d, 0x0d2f, 0 }, - { 0x0034, 0x00a2, 0 } - }, - { "", - { 0x0d1f, 0x0d4d, 0x0d1f, 0 }, - { 0x0069, 0 } - }, - { "", - { 0x0d26, 0x0d4d, 0x0d26, 0 }, - { 0x0074, 0 } - }, - { "", - { 0x0d30, 0x0d4d, 0 }, - { 0x009e, 0 } - }, - { "", - { 0x0d30, 0x0d4d, 0x200c, 0 }, - { 0x009e, 0 } - }, - { "", - { 0x0d30, 0x0d4d, 0x200d, 0 }, - { 0x009e, 0 } - }, - { "", - { 0xd15, 0xd46, 0xd3e, 0 }, - { 0x5e, 0x34, 0x58, 0 } - }, - { "", - { 0xd15, 0xd47, 0xd3e, 0 }, - { 0x5f, 0x34, 0x58, 0 } - }, - { "", - { 0xd15, 0xd46, 0xd57, 0 }, - { 0x5e, 0x34, 0x65, 0 } - }, - { "", - { 0xd15, 0xd57, 0 }, - { 0x34, 0x65, 0 } - }, - { "", - { 0xd1f, 0xd4d, 0xd1f, 0xd41, 0xd4d, 0 }, - { 0x69, 0x5b, 0x64, 0 } - }, - - {{0}} - } -}; - -static const test_set_t tests_malayalam2 = { - {"Rachana.ttf", 0}, - { - { "", - { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0 }, - { 0x385, 0xa3, 0 } - }, - { "", - { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 }, - { 0x2ff, 0 } - }, - { "", - { 0xd33, 0xd4d, 0xd33, 0 }, - { 0x3f8, 0 } - }, - { "", - { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 }, - { 0x2ff, 0 } - }, - { "", - { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0 }, - { 0xf3, 0x350, 0 } - }, - - {{0}} - } -}; - -static const test_set_t tests_sinhala = { - {"FM-MalithiUW46.ttf", 0}, - { - { "", - { 0xd9a, 0xdd9, 0xdcf, 0 }, - { 0x4a, 0x61, 0x42, 0 } - }, - { "", - { 0xd9a, 0xdd9, 0xddf, 0 }, - { 0x4a, 0x61, 0x50, 0 } - }, - { "", - { 0xd9a, 0xdd9, 0xdca, 0 }, - { 0x4a, 0x62, 0 } - }, - { "", - { 0xd9a, 0xddc, 0xdca, 0 }, - { 0x4a, 0x61, 0x42, 0x41, 0 } - }, - { "", - { 0xd9a, 0xdda, 0 }, - { 0x4a, 0x62, 0 } - }, - { "", - { 0xd9a, 0xddd, 0 }, - { 0x4a, 0x61, 0x42, 0x41, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_khmer = { - {"KhmerOS.ttf", 0}, - { - { "", - { 0x179a, 0x17cd, 0 }, - { 0x24c, 0x27f, 0 } - }, - { "", - { 0x179f, 0x17c5, 0 }, - { 0x273, 0x203, 0 } - }, - { "", - { 0x1790, 0x17d2, 0x1784, 0x17c3, 0 }, - { 0x275, 0x242, 0x182, 0 } - }, - { "", - { 0x179a, 0 }, - { 0x24c, 0 } - }, - { "", - { 0x1781, 0x17d2, 0x1798, 0x17c2, 0 }, - { 0x274, 0x233, 0x197, 0 } - }, - { "", - { 0x1798, 0x17b6, 0 }, - { 0x1cb, 0 } - }, - { "", - { 0x179a, 0x17b8, 0 }, - { 0x24c, 0x26a, 0 } - }, - { "", - { 0x1787, 0x17b6, 0 }, - { 0x1ba, 0 } - }, - { "", - { 0x1798, 0x17d2, 0x1796, 0x17bb, 0 }, - { 0x24a, 0x195, 0x26d, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_nko = { - {"DejaVuSans.ttf", 0}, - { - { "", - { 0x7ca, 0 }, - { 0x5c1, 0 } - }, - { "", - { 0x7ca, 0x7ca, 0 }, - { 0x14d9, 0x14db, 0 } - }, - { "", - { 0x7ca, 0x7fa, 0x7ca, 0 }, - { 0x14d9, 0x5ec, 0x14db, 0 } - }, - { "", - { 0x7ca, 0x7f3, 0x7ca, 0 }, - { 0x14d9, 0x5e7, 0x14db, 0 } - }, - { "", - { 0x7ca, 0x7f3, 0x7fa, 0x7ca, 0 }, - { 0x14d9, 0x5ec, 0x5e7, 0x14db, 0 } - }, - {{0}} - } -}; - -static const test_set_t tests_linearb = { - {"penuture.ttf", 0}, - { - { "", - { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 }, - { 0x5, 0x6, 0x7, 0 }, - }, - {{0}} - } -}; - - - - - -typedef struct { - FT_Library ft_library; - FT_Face ft_face; - hb_font_t *font; -} ft_fixture_t; - -static void -ft_fixture_init (ft_fixture_t *f, gconstpointer user_data) -{ - const test_t *test = user_data; - char *font_file = get_font_file (test->font_data); - FT_Error err; - - FT_Init_FreeType (&f->ft_library); - - err = FT_New_Face (f->ft_library, font_file, test->font_data->face_index, &f->ft_face); - g_assert_cmpint (err, ==, 0); - - f->font = hb_ft_font_create (f->ft_face, NULL); - - g_free (font_file); -} - -static void -ft_fixture_finish (ft_fixture_t *f, gconstpointer user_data) -{ - hb_font_destroy (f->font); - - FT_Done_Face (f->ft_face); - FT_Done_FreeType (f->ft_library); -} - -static void -test_shape_complex (ft_fixture_t *f, gconstpointer user_data) -{ - const test_t *test = user_data; - const test_data_t *data = test->test_data; - hb_buffer_t *buffer; - unsigned int i, len, expected_len; - hb_glyph_info_t *glyphs; - hb_bool_t fail; - GString *str; - - g_assert (f->font); - - if (data->comments[0]) - g_test_message ("Test comments: %s", data->comments); - - buffer = hb_buffer_create (0); - for (len = 0; data->characters[len]; len++) ; - hb_buffer_add_utf32 (buffer, data->characters, len, 0, len); - - hb_shape (f->font, buffer, NULL, 0); - - for (len = 0; data->glyphs[len]; len++) ; - expected_len = len; - - glyphs = hb_buffer_get_glyph_infos (buffer, &len); - fail = len != expected_len; - if (!fail) - for (i = 0; i < len; i++) - if (glyphs[i].codepoint != data->glyphs[i]) { - fail = TRUE; - break; - } - - str = g_string_new (""); - for (i = 0; i < len; i++) - g_string_append_printf (str, " %4d", glyphs[i].codepoint); - g_test_message ("Received glyphs: %s", str->str); - g_string_truncate (str, 0); - for (i = 0; i < expected_len; i++) - g_string_append_printf (str, " %4d", data->glyphs[i]); - g_test_message ("Expected glyphs: %s", str->str); - g_string_free (str, TRUE); - - if (fail) { - g_test_message ("FAIL"); - /* The glib test framework is useless, lets not fail for now, - * we can grep for FAIL/PASS and count manually. Sigh... */ - /*g_test_fail ();*/ - } else - g_test_message ("PASS"); - - hb_buffer_destroy (buffer); -} - -static void -test_shape_complex_skipped (gconstpointer user_data) -{ - const test_t *test = user_data; - const test_data_t *data = test->test_data; - - if (data->comments[0]) - g_test_message ("Test comments: %s", data->comments); - - g_test_message ("Skipping test"); -} - - -static void -add_test_set (const test_set_t *test_set, const char *set_name) -{ - const test_data_t *data; - char *font_file; - hb_bool_t skip; - - font_file = get_font_file (&test_set->font_data); - skip = !g_file_test (font_file, G_FILE_TEST_EXISTS); - g_free (font_file); - - for (data = test_set->test_datas; data->characters[0]; data++) { - char *flavor; - GString *str; - const hb_codepoint_t *p; - - test_t *test = g_slice_new0 (test_t); - test->font_data = &test_set->font_data; - test->test_data = data; - - str = g_string_new ("<"); - for (p = data->characters; *p; p++) - g_string_append_printf (str, "%04X,", *p); - str->str[str->len - 1] = '>'; - - flavor = g_strdup_printf ("%s/%s/%ld:%s", set_name, test_set->font_data.font_file, data - test_set->test_datas, str->str); - - g_string_free (str, TRUE); - - if (skip) - hb_test_add_data_flavor ((const void *) test, flavor, test_shape_complex_skipped); - else - hb_test_add_fixture_flavor (ft_fixture, (const void *) test, flavor, test_shape_complex); - - g_free (flavor); - } -} - - -int -main (int argc, char **argv) -{ - hb_test_init (&argc, &argv); - -#define TEST_SET(name) add_test_set (&tests_##name, #name) - - TEST_SET (devanagari1); - TEST_SET (devanagari2); - TEST_SET (bengali1); - TEST_SET (bengali2); - TEST_SET (bengali3); - TEST_SET (gurmukhi); - TEST_SET (oriya); - TEST_SET (tamil); - TEST_SET (telugu); - TEST_SET (kannada1); - TEST_SET (kannada2); - TEST_SET (malayalam1); - TEST_SET (malayalam2); - TEST_SET (sinhala); - - TEST_SET (khmer); - - TEST_SET (nko); - TEST_SET (linearb); - - return hb_test_run(); -} diff --git a/test/api/test-unicode.c b/test/api/test-unicode.c index a420bf3..88f12e7 100644 --- a/test/api/test-unicode.c +++ b/test/api/test-unicode.c @@ -351,7 +351,7 @@ static const test_pair_t script_tests[] = { 0x07B1, HB_SCRIPT_THAANA }, { 0x0E31, HB_SCRIPT_THAI }, { 0x0FD4, HB_SCRIPT_TIBETAN }, - { 0x1401, HB_SCRIPT_CANADIAN_ABORIGINAL }, + { 0x1401, HB_SCRIPT_CANADIAN_SYLLABICS }, { 0xA015, HB_SCRIPT_YI }, { 0x1700, HB_SCRIPT_TAGALOG }, { 0x1720, HB_SCRIPT_HANUNOO }, @@ -786,6 +786,7 @@ test_unicode_normalization (gconstpointer user_data) { hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data; gunichar a, b, ab; + hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN]; /* Test compose() */ @@ -849,6 +850,55 @@ test_unicode_normalization (gconstpointer user_data) g_assert (hb_unicode_decompose (uf, 0xCE31, &a, &b) && a == 0xCE20 && b == 0x11B8); g_assert (hb_unicode_decompose (uf, 0xCE20, &a, &b) && a == 0x110E && b == 0x1173); + + /* Test decompose_compatibility() */ + + /* Not decomposable */ + g_assert (hb_unicode_decompose_compatibility (uf, 0x0041, decomposed) == 0); + g_assert (hb_unicode_decompose_compatibility (uf, 0x1F632, decomposed) == 0); + + /* Singletons */ + g_assert (hb_unicode_decompose_compatibility (uf, 0x00B5, decomposed) == 1 && decomposed[0] == 0x03BC); + g_assert (hb_unicode_decompose_compatibility (uf, 0x03D6, decomposed) == 1 && decomposed[0] == 0x03C0); + + /* Arabic compatibility */ + g_assert (hb_unicode_decompose_compatibility (uf, 0xFB54, decomposed) == 1 && decomposed[0] == 0x067B); + + /* Longest decomposition ever */ + g_assert (18 <= HB_UNICODE_MAX_DECOMPOSITION_LEN); + g_assert (hb_unicode_decompose_compatibility (uf, 0xFDFA, decomposed) == 18 && decomposed[17] == 0x0645); + + /* Note: we deliberately don't test characters that have canonical decompositions but no + * compatibility decomposition against the decompose_compatibility() function as that we + * leave up to implementations (for now). */ + + /* Spaces */ + g_assert (hb_unicode_decompose_compatibility (uf, 0x2002, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2003, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2004, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2005, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2006, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2008, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2009, decomposed) == 1 && decomposed[0] == 0x0020); + g_assert (hb_unicode_decompose_compatibility (uf, 0x200A, decomposed) == 1 && decomposed[0] == 0x0020); + + /* Pairs */ + g_assert (hb_unicode_decompose_compatibility (uf, 0x0587, decomposed) == 2 && + decomposed[0] == 0x0565 && decomposed[1] == 0x0582); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2017, decomposed) == 2 && + decomposed[0] == 0x0020 && decomposed[1] == 0x0333); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2025, decomposed) == 2 && + decomposed[0] == 0x002E && decomposed[1] == 0x002E); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2033, decomposed) == 2 && + decomposed[0] == 0x2032 && decomposed[1] == 0x2032); + + /* Triples */ + g_assert (hb_unicode_decompose_compatibility (uf, 0x2026, decomposed) == 3 && + decomposed[0] == 0x002E && decomposed[1] == 0x002E && decomposed[2] == 0x002E); + g_assert (hb_unicode_decompose_compatibility (uf, 0x2034, decomposed) == 3 && + decomposed[0] == 0x2032 && decomposed[1] == 0x2032 && decomposed[2] == 0x2032); + g_assert (hb_unicode_decompose_compatibility (uf, 0x213B, decomposed) == 3 && + decomposed[0] == 0x0046 && decomposed[1] == 0x0041 && decomposed[2] == 0x0058); } diff --git a/test/api/test-version.c b/test/api/test-version.c index 4c9bd37..e6378b6 100644 --- a/test/api/test-version.c +++ b/test/api/test-version.c @@ -46,27 +46,28 @@ test_version (void) g_free (s); g_assert (0 == strcmp (HB_VERSION_STRING, hb_version_string ())); - g_assert (HB_VERSION_CHECK (major, minor, micro)); - g_assert (HB_VERSION_CHECK (major+1, minor, micro)); - g_assert (HB_VERSION_CHECK (major, minor+1, micro)); - g_assert (HB_VERSION_CHECK (major, minor, micro+1)); + g_assert (HB_VERSION_ATLEAST (major, minor, micro)); if (major) - g_assert (!HB_VERSION_CHECK (major-1, minor, micro)); + g_assert (HB_VERSION_ATLEAST (major-1, minor, micro)); if (minor) - g_assert (!HB_VERSION_CHECK (major, minor-1, micro)); + g_assert (HB_VERSION_ATLEAST (major, minor-1, micro)); if (micro) - g_assert (!HB_VERSION_CHECK (major, minor, micro-1)); + g_assert (HB_VERSION_ATLEAST (major, minor, micro-1)); + g_assert (!HB_VERSION_ATLEAST (major+1, minor, micro)); + g_assert (!HB_VERSION_ATLEAST (major, minor+1, micro)); + g_assert (!HB_VERSION_ATLEAST (major, minor, micro+1)); + g_assert (!HB_VERSION_ATLEAST (major, minor, micro+1)); - g_assert (hb_version_check (major, minor, micro)); - g_assert (hb_version_check (major+1, minor, micro)); - g_assert (hb_version_check (major, minor+1, micro)); - g_assert (hb_version_check (major, minor, micro+1)); + g_assert (hb_version_atleast (major, minor, micro)); if (major) - g_assert (!hb_version_check (major-1, minor, micro)); + g_assert (hb_version_atleast (major-1, minor, micro)); if (minor) - g_assert (!hb_version_check (major, minor-1, micro)); + g_assert (hb_version_atleast (major, minor-1, micro)); if (micro) - g_assert (!hb_version_check (major, minor, micro-1)); + g_assert (hb_version_atleast (major, minor, micro-1)); + g_assert (!hb_version_atleast (major+1, minor, micro)); + g_assert (!hb_version_atleast (major, minor+1, micro)); + g_assert (!hb_version_atleast (major, minor, micro+1)); } int |