From 61510b63c15e91d80e36a497260db0e2d6d36c66 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Tue, 16 Oct 2018 14:17:21 +0330 Subject: [PATCH] [test] Minor cleanup in test-multithread and test-ot-name (#1256) --- test/api/CMakeLists.txt | 2 +- test/api/Makefile.am | 2 +- test/api/test-multithread.c | 6 +- test/api/{test-ot-nameid.c => test-ot-name.c} | 58 ++++++++++--------- 4 files changed, 36 insertions(+), 32 deletions(-) rename test/api/{test-ot-nameid.c => test-ot-name.c} (92%) diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt index 77cb35771..0c7337cb5 100644 --- a/test/api/CMakeLists.txt +++ b/test/api/CMakeLists.txt @@ -4,7 +4,7 @@ if (HB_HAVE_GLIB) list (APPEND TEST_PROGS test-ot-color - test-ot-nameid + test-ot-name test-ot-tag test-c test-cplusplus diff --git a/test/api/Makefile.am b/test/api/Makefile.am index 0e3f9a406..bae01d2c9 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -71,7 +71,7 @@ endif TEST_PROGS += \ test-ot-color \ - test-ot-nameid \ + test-ot-name \ test-ot-tag \ $(NULL) diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c index b651b399b..7b62a0298 100644 --- a/test/api/test-multithread.c +++ b/test/api/test-multithread.c @@ -154,13 +154,15 @@ main (int argc, char **argv) hb_face_t *face = hb_face_create (blob, 0); font = hb_font_create (face); - hb_ot_font_set_funcs (font); - + /* Fill the reference */ ref_buffer = hb_buffer_create (); fill_the_buffer (ref_buffer); + /* Unnecessary, since version 2 it is ot-font by default */ + hb_ot_font_set_funcs (font); test_body (); + /* Test hb-ft in multithread */ hb_ft_font_set_funcs (font); test_body (); diff --git a/test/api/test-ot-nameid.c b/test/api/test-ot-name.c similarity index 92% rename from test/api/test-ot-nameid.c rename to test/api/test-ot-name.c index 1205190d2..477e67f0d 100644 --- a/test/api/test-ot-nameid.c +++ b/test/api/test-ot-name.c @@ -23,35 +23,16 @@ * */ -#include +#include "hb-test.h" + #include -#include static const char *font_path = "fonts/cv01.otf"; +static hb_face_t *face; -int -main (int argc, char **argv) +static void +test_ot_layout_feature_get_name_ids_and_characters () { - g_test_init (&argc, &argv, NULL); - -#if GLIB_CHECK_VERSION(2,37,2) - gchar *default_path = g_test_build_filename (G_TEST_DIST, font_path, NULL); -#else - gchar *default_path = g_strdup (font_path); -#endif - - hb_blob_t *blob; - hb_face_t *face; - hb_font_t *font; - - char *path = argc > 1 && *argv[1] ? argv[1] : (char *) default_path; - blob = hb_blob_create_from_file (path); - if (hb_blob_get_length (blob) == 0) - g_error ("Font not found."); - - face = hb_face_create (blob, 0); - font = hb_font_create (face); - hb_tag_t cv01 = HB_TAG ('c','v','0','1'); unsigned int feature_index; if (!hb_ot_layout_language_find_feature (face, @@ -89,12 +70,33 @@ main (int argc, char **argv) g_assert (char_count == 2); g_assert (characters[0] == 10); g_assert (characters[1] == 24030); +} - hb_font_destroy (font); +int +main (int argc, char **argv) +{ + g_test_init (&argc, &argv, NULL); + +#if GLIB_CHECK_VERSION(2,37,2) + gchar *default_path = g_test_build_filename (G_TEST_DIST, font_path, NULL); +#else + gchar *default_path = g_strdup (font_path); +#endif + + hb_blob_t *blob; + + char *path = argc > 1 && *argv[1] ? argv[1] : (char *) default_path; + blob = hb_blob_create_from_file (path); + if (hb_blob_get_length (blob) == 0) + g_error ("Font not found."); + + face = hb_face_create (blob, 0); + + hb_test_add (test_ot_layout_feature_get_name_ids_and_characters); + + unsigned int result = hb_test_run (); hb_face_destroy (face); hb_blob_destroy (blob); - g_free (default_path); - - return 0; + return result; }