From e4e4d66523f1530cbe4a047339b3faf871c042b1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 6 Apr 2025 00:12:22 -0600 Subject: [PATCH] [test/api] Test remaining tests to TAP --- test/api/test-c.c | 22 +++++++++++++++------- test/api/test-cplusplus.cc | 17 ++++++++++++++--- test/api/test-multithread.c | 9 ++++++--- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/test/api/test-c.c b/test/api/test-c.c index d0bdc9d6d..9434853fb 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -26,10 +26,7 @@ /* This file tests that all headers can be included from C files */ - -#ifdef HAVE_CONFIG_H -#include -#endif +#include "hb-test.h" #include #include @@ -77,9 +74,20 @@ #endif #ifndef NO_MAIN -int -main (void) +static void +test_list_shapers (void) { - return !*hb_shape_list_shapers (); + const char *first = *hb_shape_list_shapers (); + g_assert (first); +} + +int +main (int argc, char **argv) +{ + hb_test_init (&argc, &argv); + + hb_test_add (test_list_shapers); + + return hb_test_run (); } #endif diff --git a/test/api/test-cplusplus.cc b/test/api/test-cplusplus.cc index 74e4fb265..50cae8a7f 100644 --- a/test/api/test-cplusplus.cc +++ b/test/api/test-cplusplus.cc @@ -45,8 +45,8 @@ #include #include -int -main () +static void +test_smart_ptrs (void) { hb_buffer_t *b = hb_buffer_create (); hb::shared_ptr pb {b}; @@ -100,5 +100,16 @@ main () assert (hash2 (pb4) == hash2 (pb2)); assert (hash (b) == hash3 (pb5)); - return pb == pb.get_empty () || pb == pb2; + g_assert (pb != pb.get_empty ()); + g_assert (pb != pb2); +} + +int +main (int argc, char **argv) +{ + hb_test_init (&argc, &argv); + + hb_test_add (test_smart_ptrs); + + return hb_test_run (); } diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c index 90bde064e..728290598 100644 --- a/test/api/test-multithread.c +++ b/test/api/test-multithread.c @@ -91,8 +91,9 @@ thread_func (void *data) } static void -test_body (const char *backend) +test_body (gconstpointer data) { + const char *backend = (const char *) data; bool ret = hb_font_set_funcs_using (font, backend); g_assert (ret); @@ -147,12 +148,14 @@ main (int argc, char **argv) fill_the_buffer (ref_buffer); for (const char **font_funcs = hb_font_list_funcs (); *font_funcs; font_funcs++) - test_body (*font_funcs); + hb_test_add_data_flavor (*font_funcs, *font_funcs, test_body); + + int ret = hb_test_run (); hb_buffer_destroy (ref_buffer); hb_font_destroy (font); hb_face_destroy (face); - return 0; + return ret; }