Merge pull request #5260 from harfbuzz/tap

Use TAP protocol for tests
This commit is contained in:
Behdad Esfahbod 2025-04-06 14:30:07 -06:00 committed by GitHub
commit 1f1cbb64ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 1264 additions and 1228 deletions

View file

@ -149,8 +149,9 @@ jobs:
executor: win64-executor
steps:
- checkout
- run: dpkg --add-architecture i386
- run: apt update
- run: DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-x86-64 zip wine wine64
- run: DEBIAN_FRONTEND=noninteractive apt install -y ninja-build python3 python3-pip python3-venv git g++-mingw-w64-x86-64 zip wine wine64 wine32:i386
- run: |
export LANG=en_US.UTF-8
python3 -m venv venv

View file

@ -22,30 +22,30 @@ if not OBJS:
stat = 0
tested = 0
for obj in OBJS:
result = subprocess.run(objdump.split () + ['-t', obj], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run(objdump.split () + ['-t'] + OBJS, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode:
if result.stderr.find (b'not recognized') != -1:
# https://github.com/harfbuzz/harfbuzz/issues/3019
print ('objdump %s returned "not recognized", skipping' % obj)
continue
print ('objdump %s returned error:\n%s' % (obj, result.stderr.decode ('utf-8')))
stat = 2
if result.returncode:
if result.stderr.find (b'not recognized') != -1:
# https://github.com/harfbuzz/harfbuzz/issues/3019
print ('objdump %s returned "not recognized", skipping')
else:
print ('objdump returned error:\n%s' % (result.stderr.decode ('utf-8')))
stat = 2
else:
tested = 1
result = result.stdout.decode ('utf-8')
result = result.stdout.decode ('utf-8')
# Checking that no object file has static initializers
for l in re.findall (r'^.*\.[cd]tors.*$', result, re.MULTILINE):
if not re.match (r'.*\b0+\b', l):
print ('Ouch, %s has static initializers/finalizers' % obj)
stat = 1
# Checking that no object file has static initializers
for l in re.findall (r'^.*\.[cd]tors.*$', result, re.MULTILINE):
if not re.match (r'.*\b0+\b', l):
print ('Ouch, library has static initializers/finalizers')
stat = 1
# Checking that no object file has lazy static C++ constructors/destructors or other such stuff
if ('__cxa_' in result) and ('__ubsan_handle' not in result):
print ('Ouch, %s has lazy static C++ constructors/destructors or other such stuff' % obj)
stat = 1
# Checking that no object file has lazy static C++ constructors/destructors or other such stuff
if ('__cxa_' in result) and ('__ubsan_handle' not in result):
print ('Ouch, library has lazy static C++ constructors/destructors or other such stuff')
stat = 1
tested += 1
sys.exit (stat if tested else 77)

View file

@ -73,7 +73,7 @@ hb_subset_test_create_subset (hb_face_t *source,
hb_subset_input_t *input)
{
hb_face_t *subset = hb_subset_or_fail (source, input);
g_assert (subset);
g_assert_true (subset);
hb_subset_input_destroy (input);
return subset;
@ -87,7 +87,6 @@ hb_subset_test_check (hb_face_t *expected,
hb_blob_t *expected_blob, *actual_blob;
expected_blob = hb_face_reference_table (expected, table);
actual_blob = hb_face_reference_table (actual, table);
fprintf(stderr, "comparing %c%c%c%c, expected %d bytes, actual %d bytes\n", HB_UNTAG(table), hb_blob_get_length(expected_blob), hb_blob_get_length (actual_blob));
if (hb_blob_get_length (expected_blob) != 0 ||
hb_blob_get_length (actual_blob) != 0)

View file

@ -166,7 +166,6 @@ static inline void hb_test_assert_blobs_equal (hb_blob_t *expected_blob, hb_blob
int expected = *(raw_expected + i);
int actual = *(raw_actual + i);
if (expected != actual) fprintf(stderr, "+%u %02x != %02x\n", i, expected, actual);
else fprintf(stderr, "+%u %02x\n", i, expected);
}
}
g_assert_cmpint(0, ==, memcmp(raw_expected, raw_actual, expected_length));

View file

@ -117,9 +117,12 @@ foreach source : tests
endif
test(test_name, executable(test_name, source,
cpp_args: cpp_args,
include_directories: [incconfig],
dependencies: deps,
install: false,
), env: env, suite: suite)
cpp_args: cpp_args,
include_directories: [incconfig],
dependencies: deps,
install: false,
),
protocol: 'tap',
env: env,
suite: suite)
endforeach

View file

@ -108,11 +108,11 @@ test_aat_has (void)
{
hb_face_t *morx = hb_test_open_font_file ("fonts/aat-morx.ttf");
hb_face_t *trak;
g_assert (hb_aat_layout_has_substitution (morx));
g_assert_true (hb_aat_layout_has_substitution (morx));
hb_face_destroy (morx);
trak = hb_test_open_font_file ("fonts/aat-trak.ttf");
g_assert (hb_aat_layout_has_tracking (trak));
g_assert_true (hb_aat_layout_has_tracking (trak));
hb_face_destroy (trak);
}

View file

@ -36,19 +36,19 @@ test_ot_layout_font_extents (void)
hb_font_extents_t extents;
g_assert (hb_ot_layout_get_font_extents2 (font, HB_DIRECTION_LTR,
HB_SCRIPT_LATIN, HB_LANGUAGE_INVALID,
&extents));
g_assert_true (hb_ot_layout_get_font_extents2 (font, HB_DIRECTION_LTR,
HB_SCRIPT_LATIN, HB_LANGUAGE_INVALID,
&extents));
g_assert_cmpint (extents.ascender, ==, 2000);
g_assert (hb_ot_layout_get_font_extents2 (font, HB_DIRECTION_LTR,
HB_SCRIPT_LATIN, hb_language_from_string ("xx", -1),
&extents));
g_assert_true (hb_ot_layout_get_font_extents2 (font, HB_DIRECTION_LTR,
HB_SCRIPT_LATIN, hb_language_from_string ("xx", -1),
&extents));
g_assert_cmpint (extents.ascender, ==, 2000);
g_assert (!hb_ot_layout_get_font_extents2 (font, HB_DIRECTION_LTR,
HB_SCRIPT_ARABIC, HB_LANGUAGE_INVALID,
&extents));
g_assert_true (!hb_ot_layout_get_font_extents2 (font, HB_DIRECTION_LTR,
HB_SCRIPT_ARABIC, HB_LANGUAGE_INVALID,
&extents));
g_assert_cmpint (extents.ascender, ==, 3000);
hb_font_destroy (font);

View file

@ -35,22 +35,22 @@ test_ot_layout_base (void)
hb_font_t *font = hb_font_create (face);
hb_position_t position;
g_assert (hb_ot_layout_get_baseline (font, HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT, HB_DIRECTION_TTB,
HB_TAG ('h','a','n','i'),
HB_TAG ('E','N','G',' '),
&position));
g_assert_true (hb_ot_layout_get_baseline (font, HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT, HB_DIRECTION_TTB,
HB_TAG ('h','a','n','i'),
HB_TAG ('E','N','G',' '),
&position));
g_assert_cmpint (46, ==, position);
g_assert (hb_ot_layout_get_baseline2 (font, HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT, HB_DIRECTION_TTB,
HB_SCRIPT_HAN,
hb_language_from_string ("en", -1),
&position));
g_assert_true (hb_ot_layout_get_baseline2 (font, HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT, HB_DIRECTION_TTB,
HB_SCRIPT_HAN,
hb_language_from_string ("en", -1),
&position));
g_assert_cmpint (46, ==, position);
g_assert (!hb_ot_layout_get_baseline (font, HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT, HB_DIRECTION_TTB,
HB_TAG ('h','a','n','i'),
HB_TAG ('E','N','G',' '),
&position));
g_assert_true (!hb_ot_layout_get_baseline (font, HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT, HB_DIRECTION_TTB,
HB_TAG ('h','a','n','i'),
HB_TAG ('E','N','G',' '),
&position));
hb_font_destroy (font);
hb_face_destroy (face);

View file

@ -50,31 +50,31 @@ test_blob_empty (void)
const char *data;
char *data_writable;
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));
g_assert_true (hb_blob_is_immutable (hb_blob_get_empty ()));
g_assert_true (hb_blob_get_empty () != NULL);
g_assert_true (hb_blob_get_empty () == hb_blob_create (NULL, 0, HB_MEMORY_MODE_READONLY, NULL, NULL));
g_assert_true (hb_blob_get_empty () == hb_blob_create ("asdf", 0, HB_MEMORY_MODE_READONLY, NULL, NULL));
g_assert_true (hb_blob_get_empty () == hb_blob_create (NULL, -1, HB_MEMORY_MODE_READONLY, NULL, NULL));
g_assert_true (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 ());
g_assert_true (blob == hb_blob_get_empty ());
len = hb_blob_get_length (blob);
g_assert_cmpint (len, ==, 0);
data = hb_blob_get_data (blob, NULL);
g_assert (data == NULL);
g_assert_true (data == NULL);
data = hb_blob_get_data (blob, &len);
g_assert (data == NULL);
g_assert_true (data == NULL);
g_assert_cmpint (len, ==, 0);
data_writable = hb_blob_get_data_writable (blob, NULL);
g_assert (data_writable == NULL);
g_assert_true (data_writable == NULL);
data_writable = hb_blob_get_data_writable (blob, &len);
g_assert (data_writable == NULL);
g_assert_true (data_writable == NULL);
g_assert_cmpint (len, ==, 0);
}
@ -126,7 +126,7 @@ get_pagesize (void)
pagesize = (uintptr_t) getpagesize ();
#endif
g_assert (pagesize != (uintptr_t) -1);
g_assert_true (pagesize != (uintptr_t) -1);
return pagesize;
}
@ -175,7 +175,7 @@ fixture_init (fixture_t *fixture, gconstpointer user_data)
uintptr_t pagesize = get_pagesize ();
data = mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
g_assert (data != (char *) -1);
g_assert_true (data != (char *) -1);
memcpy ((char *) data, test_data, sizeof (test_data));
mprotect ((char *) data, pagesize, PROT_READ);
len = sizeof (test_data);
@ -212,7 +212,7 @@ test_blob (fixture_t *fixture, gconstpointer user_data)
char *data_writable;
unsigned int i;
g_assert (b);
g_assert_true (b);
len = hb_blob_get_length (b);
g_assert_cmpint (len, ==, fixture->len);
@ -220,45 +220,45 @@ test_blob (fixture_t *fixture, gconstpointer user_data)
data = hb_blob_get_data (b, &len);
g_assert_cmpint (len, ==, fixture->len);
if (mm == HB_MEMORY_MODE_DUPLICATE) {
g_assert (data != fixture->data);
g_assert_true (data != fixture->data);
g_assert_cmpint (fixture->freed, ==, 1);
mm = HB_MEMORY_MODE_WRITABLE;
} else {
g_assert (data == fixture->data);
g_assert_true (data == fixture->data);
g_assert_cmpint (fixture->freed, ==, 0);
}
data_writable = hb_blob_get_data_writable (b, &len);
g_assert_cmpint (len, ==, fixture->len);
g_assert (data_writable);
g_assert (0 == memcmp (data_writable, fixture->data, fixture->len));
g_assert_true (data_writable);
g_assert_true (0 == memcmp (data_writable, fixture->data, fixture->len));
if (mm == HB_MEMORY_MODE_READONLY) {
g_assert (data_writable != data);
g_assert_true (data_writable != data);
g_assert_cmpint (fixture->freed, ==, 1);
} else {
g_assert (data_writable == data);
g_assert_true (data_writable == data);
}
data = hb_blob_get_data (b, &len);
g_assert_cmpint (len, ==, fixture->len);
g_assert (data == data_writable);
g_assert_true (data == data_writable);
memset (data_writable, 0, fixture->len);
/* Now, make it immutable and watch get_data_writable() fail */
g_assert (!hb_blob_is_immutable (b));
g_assert_true (!hb_blob_is_immutable (b));
hb_blob_make_immutable (b);
g_assert (hb_blob_is_immutable (b));
g_assert_true (hb_blob_is_immutable (b));
data_writable = hb_blob_get_data_writable (b, &len);
g_assert (!data_writable);
g_assert_true (!data_writable);
g_assert_cmpint (len, ==, 0);
data = hb_blob_get_data (b, &len);
g_assert_cmpint (len, ==, fixture->len);
for (i = 0; i < len; i++)
g_assert ('\0' == data[i]);
g_assert_true ('\0' == data[i]);
}
static void
@ -283,43 +283,43 @@ test_blob_subblob (fixture_t *fixture, gconstpointer user_data)
/* A sub-blob is always created READONLY. */
g_assert (b);
g_assert_true (b);
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);
g_assert_true (data == fixture->data + 1);
data_writable = hb_blob_get_data_writable (b, &len);
g_assert_cmpint (len, ==, fixture->len - 2);
g_assert (data_writable);
g_assert_true (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_true (0 == memcmp (data_writable, fixture->data + 1, fixture->len - 2));
g_assert_true (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);
g_assert_true (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));
g_assert_true (!hb_blob_is_immutable (b));
hb_blob_make_immutable (b);
g_assert (hb_blob_is_immutable (b));
g_assert_true (hb_blob_is_immutable (b));
data_writable = hb_blob_get_data_writable (b, &len);
g_assert (!data_writable);
g_assert_true (!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]);
g_assert_true ('\0' == data[i]);
}

View file

@ -106,74 +106,74 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data HB_UNUSED)
/* test default properties */
g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
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_true (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
g_assert_true (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert_true (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert_true (hb_buffer_get_language (b) == NULL);
/* test property changes are retained */
ufuncs = hb_unicode_funcs_create (NULL);
hb_buffer_set_unicode_funcs (b, ufuncs);
hb_unicode_funcs_destroy (ufuncs);
g_assert (hb_buffer_get_unicode_funcs (b) == ufuncs);
g_assert_true (hb_buffer_get_unicode_funcs (b) == ufuncs);
hb_buffer_set_direction (b, HB_DIRECTION_RTL);
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_RTL);
g_assert_true (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);
g_assert_true (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));
g_assert_true (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);
g_assert_true (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);
g_assert_true (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);
g_assert_true (hb_buffer_get_unicode_funcs (b) == ufuncs);
g_assert_true (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert_true (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert_true (hb_buffer_get_language (b) == NULL);
/* but not these: */
g_assert (hb_buffer_get_flags (b) != HB_BUFFER_FLAG_DEFAULT);
g_assert (hb_buffer_get_replacement_codepoint (b) != HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
g_assert_true (hb_buffer_get_flags (b) != HB_BUFFER_FLAG_DEFAULT);
g_assert_true (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);
g_assert_true (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);
g_assert_true (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));
g_assert_true (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);
g_assert_true (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);
g_assert_true (hb_buffer_get_replacement_codepoint (b) == (unsigned int) -1);
hb_buffer_reset (b);
g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
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_FLAG_DEFAULT);
g_assert (hb_buffer_get_replacement_codepoint (b) == HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
g_assert_true (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
g_assert_true (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert_true (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert_true (hb_buffer_get_language (b) == NULL);
g_assert_true (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_DEFAULT);
g_assert_true (hb_buffer_get_replacement_codepoint (b) == HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT);
}
static void
@ -269,7 +269,7 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
/* test setting length */
/* enlarge */
g_assert (hb_buffer_set_length (b, 10));
g_assert_true (hb_buffer_set_length (b, 10));
glyphs = hb_buffer_get_glyph_infos (b, NULL);
g_assert_cmpint (hb_buffer_get_length (b), ==, 10);
for (i = 0; i < 5; i++)
@ -277,14 +277,14 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
for (i = 5; i < 10; i++)
g_assert_cmphex (glyphs[i].codepoint, ==, 0);
/* shrink */
g_assert (hb_buffer_set_length (b, 3));
g_assert_true (hb_buffer_set_length (b, 3));
glyphs = hb_buffer_get_glyph_infos (b, NULL);
g_assert_cmpint (hb_buffer_get_length (b), ==, 3);
for (i = 0; i < 3; i++)
g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
g_assert (hb_buffer_allocation_successful (b));
g_assert_true (hb_buffer_allocation_successful (b));
/* test reset clears content */
@ -325,40 +325,40 @@ test_buffer_allocation (fixture_t *fixture, gconstpointer user_data HB_UNUSED)
g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
g_assert (hb_buffer_pre_allocate (b, 100));
g_assert_true (hb_buffer_pre_allocate (b, 100));
g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
g_assert (hb_buffer_allocation_successful (b));
g_assert_true (hb_buffer_allocation_successful (b));
/* lets try a huge allocation, make sure it fails */
g_assert (!hb_buffer_pre_allocate (b, (unsigned int) -1));
g_assert_true (!hb_buffer_pre_allocate (b, (unsigned int) -1));
g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_allocation_successful (b));
/* small one again */
g_assert (hb_buffer_pre_allocate (b, 50));
g_assert_true (hb_buffer_pre_allocate (b, 50));
g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_allocation_successful (b));
hb_buffer_reset (b);
g_assert (hb_buffer_allocation_successful (b));
g_assert_true (hb_buffer_allocation_successful (b));
/* all allocation and size */
g_assert (!hb_buffer_pre_allocate (b, ((unsigned int) -1) / 20 + 1));
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_pre_allocate (b, ((unsigned int) -1) / 20 + 1));
g_assert_true (!hb_buffer_allocation_successful (b));
hb_buffer_reset (b);
g_assert (hb_buffer_allocation_successful (b));
g_assert_true (hb_buffer_allocation_successful (b));
/* technically, this one can actually pass on 64bit machines, but
* I'm doubtful that any malloc allows 4GB allocations at a time.
* But let's only enable it on a 32-bit machine. */
if (sizeof (long) == 4) {
g_assert (!hb_buffer_pre_allocate (b, ((unsigned int) -1) / 20 - 1));
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_pre_allocate (b, ((unsigned int) -1) / 20 - 1));
g_assert_true (!hb_buffer_allocation_successful (b));
}
hb_buffer_reset (b);
g_assert (hb_buffer_allocation_successful (b));
g_assert_true (hb_buffer_allocation_successful (b));
}
@ -698,9 +698,9 @@ test_buffer_utf8_validity (void)
if (glyphs[j].codepoint == (hb_codepoint_t) -1)
break;
g_assert (test->valid ? j == len : j < len);
g_assert_true (test->valid ? j == len : j < len);
if (!test->valid)
g_assert (glyphs[j].cluster == test->offset);
g_assert_true (glyphs[j].cluster == test->offset);
}
hb_buffer_destroy (b);
@ -816,8 +816,8 @@ static void
test_empty (hb_buffer_t *b)
{
g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
g_assert (!hb_buffer_get_glyph_infos (b, NULL));
g_assert (!hb_buffer_get_glyph_positions (b, NULL));
g_assert_true (!hb_buffer_get_glyph_infos (b, NULL));
g_assert_true (!hb_buffer_get_glyph_positions (b, NULL));
}
static void
@ -825,10 +825,10 @@ test_buffer_empty (void)
{
hb_buffer_t *b = hb_buffer_get_empty ();
g_assert (hb_buffer_get_empty ());
g_assert (hb_buffer_get_empty () == b);
g_assert_true (hb_buffer_get_empty ());
g_assert_true (hb_buffer_get_empty () == b);
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_allocation_successful (b));
test_empty (b);
@ -839,21 +839,21 @@ test_buffer_empty (void)
hb_buffer_reverse (b);
hb_buffer_reverse_clusters (b);
g_assert (!hb_buffer_set_length (b, 10));
g_assert_true (!hb_buffer_set_length (b, 10));
test_empty (b);
g_assert (hb_buffer_set_length (b, 0));
g_assert_true (hb_buffer_set_length (b, 0));
test_empty (b);
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_allocation_successful (b));
hb_buffer_reset (b);
test_empty (b);
g_assert (!hb_buffer_allocation_successful (b));
g_assert_true (!hb_buffer_allocation_successful (b));
}
typedef struct {
@ -917,7 +917,7 @@ test_buffer_serialize_deserialize (void)
}
}
else
g_assert (!ret);
g_assert_true (!ret);
hb_buffer_destroy (b);

View file

@ -26,10 +26,7 @@
/* This file tests that all headers can be included from C files */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "hb-test.h"
#include <hb.h>
#include <hb-subset.h>
@ -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_true (first);
}
int
main (int argc, char **argv)
{
hb_test_init (&argc, &argv);
hb_test_add (test_list_shapers);
return hb_test_run ();
}
#endif

View file

@ -37,13 +37,13 @@ test_collect_unicodes_format4 (void)
hb_face_collect_unicodes (face, codepoints);
cp = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x61, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x62, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x63, ==, cp);
g_assert (!hb_set_next (codepoints, &cp));
g_assert_true (!hb_set_next (codepoints, &cp));
hb_set_destroy (codepoints);
hb_face_destroy (face);
@ -59,11 +59,11 @@ test_collect_unicodes_format12_notdef (void)
hb_face_collect_unicodes (face, codepoints);
cp = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x20, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x21, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x22, ==, cp);
hb_set_destroy (codepoints);
@ -80,13 +80,13 @@ test_collect_unicodes_format12 (void)
hb_face_collect_unicodes (face, codepoints);
cp = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x61, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x62, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_cmpuint (0x63, ==, cp);
g_assert (!hb_set_next (codepoints, &cp));
g_assert_true (!hb_set_next (codepoints, &cp));
hb_set_destroy (codepoints);
hb_face_destroy (face);
@ -104,21 +104,21 @@ test_collect_unicodes (void)
hb_face_collect_unicodes (face, codepoints);
hb_face_collect_nominal_glyph_mapping (face, mapping, codepoints2);
g_assert (hb_set_is_equal (codepoints, codepoints2));
g_assert_true (hb_set_is_equal (codepoints, codepoints2));
g_assert_cmpuint (hb_set_get_population (codepoints), ==, 3);
g_assert_cmpuint (hb_map_get_population (mapping), ==, 3);
cp = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (codepoints, &cp));
g_assert (hb_map_has (mapping, cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_true (hb_map_has (mapping, cp));
g_assert_cmpuint (0x61, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert (hb_map_has (mapping, cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_true (hb_map_has (mapping, cp));
g_assert_cmpuint (0x62, ==, cp);
g_assert (hb_set_next (codepoints, &cp));
g_assert (hb_map_has (mapping, cp));
g_assert_true (hb_set_next (codepoints, &cp));
g_assert_true (hb_map_has (mapping, cp));
g_assert_cmpuint (0x63, ==, cp);
g_assert (!hb_set_next (codepoints, &cp));
g_assert_true (!hb_set_next (codepoints, &cp));
hb_set_destroy (codepoints);
hb_set_destroy (codepoints2);

View file

@ -53,36 +53,36 @@ test_types_direction (void)
g_assert_cmpint ((signed) HB_DIRECTION_INVALID, ==, 0);
g_assert_cmpint (HB_DIRECTION_LTR, !=, 0);
g_assert (HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_LTR));
g_assert (HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_RTL));
g_assert (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_TTB));
g_assert (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_INVALID));
g_assert_true (HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_LTR));
g_assert_true (HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_RTL));
g_assert_true (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_TTB));
g_assert_true (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_BTT));
g_assert_true (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_INVALID));
g_assert (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_LTR));
g_assert (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_RTL));
g_assert (HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_TTB));
g_assert (HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_INVALID));
g_assert_true (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_LTR));
g_assert_true (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_RTL));
g_assert_true (HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_TTB));
g_assert_true (HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_BTT));
g_assert_true (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_INVALID));
g_assert (HB_DIRECTION_IS_FORWARD (HB_DIRECTION_LTR));
g_assert (HB_DIRECTION_IS_FORWARD (HB_DIRECTION_TTB));
g_assert (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_RTL));
g_assert (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_INVALID));
g_assert_true (HB_DIRECTION_IS_FORWARD (HB_DIRECTION_LTR));
g_assert_true (HB_DIRECTION_IS_FORWARD (HB_DIRECTION_TTB));
g_assert_true (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_RTL));
g_assert_true (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_BTT));
g_assert_true (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_INVALID));
g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_LTR));
g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_TTB));
g_assert (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_RTL));
g_assert (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_INVALID));
g_assert_true (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_LTR));
g_assert_true (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_TTB));
g_assert_true (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_RTL));
g_assert_true (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_BTT));
g_assert_true (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_INVALID));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_LTR));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_TTB));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_RTL));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_VALID (HB_DIRECTION_INVALID));
g_assert (!HB_DIRECTION_IS_VALID ((hb_direction_t) 0x12345678));
g_assert_true (HB_DIRECTION_IS_VALID (HB_DIRECTION_LTR));
g_assert_true (HB_DIRECTION_IS_VALID (HB_DIRECTION_TTB));
g_assert_true (HB_DIRECTION_IS_VALID (HB_DIRECTION_RTL));
g_assert_true (HB_DIRECTION_IS_VALID (HB_DIRECTION_BTT));
g_assert_true (!HB_DIRECTION_IS_VALID (HB_DIRECTION_INVALID));
g_assert_true (!HB_DIRECTION_IS_VALID ((hb_direction_t) 0x12345678));
g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_LTR), ==, HB_DIRECTION_RTL);
g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_RTL), ==, HB_DIRECTION_LTR);
@ -100,11 +100,11 @@ test_types_direction (void)
g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("right-to-left", -1));
g_assert_cmpint (HB_DIRECTION_TTB, ==, hb_direction_from_string ("ttb", -1));
g_assert (0 == strcmp ("ltr", hb_direction_to_string (HB_DIRECTION_LTR)));
g_assert (0 == strcmp ("rtl", hb_direction_to_string (HB_DIRECTION_RTL)));
g_assert (0 == strcmp ("ttb", hb_direction_to_string (HB_DIRECTION_TTB)));
g_assert (0 == strcmp ("btt", hb_direction_to_string (HB_DIRECTION_BTT)));
g_assert (0 == strcmp ("invalid", hb_direction_to_string (HB_DIRECTION_INVALID)));
g_assert_true (0 == strcmp ("ltr", hb_direction_to_string (HB_DIRECTION_LTR)));
g_assert_true (0 == strcmp ("rtl", hb_direction_to_string (HB_DIRECTION_RTL)));
g_assert_true (0 == strcmp ("ttb", hb_direction_to_string (HB_DIRECTION_TTB)));
g_assert_true (0 == strcmp ("btt", hb_direction_to_string (HB_DIRECTION_BTT)));
g_assert_true (0 == strcmp ("invalid", hb_direction_to_string (HB_DIRECTION_INVALID)));
}
static void
@ -184,30 +184,30 @@ test_types_language (void)
hb_language_t fa_ir = hb_language_from_string ("fa-ir", -1);
hb_language_t en = hb_language_from_string ("en", -1);
g_assert (HB_LANGUAGE_INVALID == NULL);
g_assert_true (HB_LANGUAGE_INVALID == NULL);
g_assert (fa != NULL);
g_assert (fa_IR != NULL);
g_assert (fa_IR == fa_ir);
g_assert_true (fa != NULL);
g_assert_true (fa_IR != NULL);
g_assert_true (fa_IR == fa_ir);
g_assert (en != NULL);
g_assert (en != fa);
g_assert_true (en != NULL);
g_assert_true (en != fa);
/* Test recall */
g_assert (en == hb_language_from_string ("en", -1));
g_assert (en == hb_language_from_string ("eN", -1));
g_assert (en == hb_language_from_string ("Enx", 2));
g_assert_true (en == hb_language_from_string ("en", -1));
g_assert_true (en == hb_language_from_string ("eN", -1));
g_assert_true (en == hb_language_from_string ("Enx", 2));
g_assert (HB_LANGUAGE_INVALID == hb_language_from_string (NULL, -1));
g_assert (HB_LANGUAGE_INVALID == hb_language_from_string ("", -1));
g_assert (HB_LANGUAGE_INVALID == hb_language_from_string ("en", 0));
g_assert (HB_LANGUAGE_INVALID != hb_language_from_string ("en", 1));
g_assert (NULL == hb_language_to_string (HB_LANGUAGE_INVALID));
g_assert_true (HB_LANGUAGE_INVALID == hb_language_from_string (NULL, -1));
g_assert_true (HB_LANGUAGE_INVALID == hb_language_from_string ("", -1));
g_assert_true (HB_LANGUAGE_INVALID == hb_language_from_string ("en", 0));
g_assert_true (HB_LANGUAGE_INVALID != hb_language_from_string ("en", 1));
g_assert_true (NULL == hb_language_to_string (HB_LANGUAGE_INVALID));
/* Not sure how to test this better. Setting env vars
* here doesn't sound like the right approach, and I'm
* not sure that it even works. */
g_assert (HB_LANGUAGE_INVALID != hb_language_get_default ());
g_assert_true (HB_LANGUAGE_INVALID != hb_language_get_default ());
}
static void
@ -216,105 +216,105 @@ test_types_feature (void)
hb_feature_t feature;
char buf[100];
g_assert (hb_feature_from_string ("abcd", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("abcd=1", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd=1", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("+abcd", -1, &feature));
g_assert_true (hb_feature_from_string ("+abcd", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("abcd=0", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd=0", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("-abcd", buf));
g_assert_true (0 == strcmp ("-abcd", buf));
g_assert (hb_feature_from_string ("-abcd", -1, &feature));
g_assert_true (hb_feature_from_string ("-abcd", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("-abcd", buf));
g_assert_true (0 == strcmp ("-abcd", buf));
g_assert (hb_feature_from_string ("abcd=2", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd=2", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd=2", buf));
g_assert_true (0 == strcmp ("abcd=2", buf));
g_assert (hb_feature_from_string ("+abcd=2", -1, &feature));
g_assert_true (hb_feature_from_string ("+abcd=2", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd=2", buf));
g_assert_true (0 == strcmp ("abcd=2", buf));
g_assert (hb_feature_from_string ("-abcd=2", -1, &feature));
g_assert_true (hb_feature_from_string ("-abcd=2", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd=2", buf));
g_assert_true (0 == strcmp ("abcd=2", buf));
g_assert (hb_feature_from_string ("\"abcd\" on", -1, &feature));
g_assert_true (hb_feature_from_string ("\"abcd\" on", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("\"abcd\" off", -1, &feature));
g_assert_true (hb_feature_from_string ("\"abcd\" off", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("-abcd", buf));
g_assert_true (0 == strcmp ("-abcd", buf));
g_assert (hb_feature_from_string ("\"abcd\" 1", -1, &feature));
g_assert_true (hb_feature_from_string ("\"abcd\" 1", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("\"abcd\" 0", -1, &feature));
g_assert_true (hb_feature_from_string ("\"abcd\" 0", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("-abcd", buf));
g_assert_true (0 == strcmp ("-abcd", buf));
g_assert (hb_feature_from_string ("\"abcd\" 2", -1, &feature));
g_assert_true (hb_feature_from_string ("\"abcd\" 2", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd=2", buf));
g_assert_true (0 == strcmp ("abcd=2", buf));
g_assert (hb_feature_from_string ("abcd[0]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[0]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[]", buf));
g_assert_true (0 == strcmp ("abcd[]", buf));
g_assert (hb_feature_from_string ("abcd[1]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1]", buf));
g_assert_true (0 == strcmp ("abcd[1]", buf));
g_assert (hb_feature_from_string ("abcd[1]=1", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1]=1", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1]", buf));
g_assert_true (0 == strcmp ("abcd[1]", buf));
g_assert (hb_feature_from_string ("abcd[1]=2", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1]=2", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1]=2", buf));
g_assert_true (0 == strcmp ("abcd[1]=2", buf));
g_assert (hb_feature_from_string ("abcd[1]=0", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1]=0", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("-abcd[1]", buf));
g_assert_true (0 == strcmp ("-abcd[1]", buf));
g_assert (hb_feature_from_string ("abcd[]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("abcd[:]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[:]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd", buf));
g_assert_true (0 == strcmp ("abcd", buf));
g_assert (hb_feature_from_string ("abcd[1:]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1:]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1:]", buf));
g_assert_true (0 == strcmp ("abcd[1:]", buf));
g_assert (hb_feature_from_string ("abcd[:1]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[:1]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[]", buf));
g_assert_true (0 == strcmp ("abcd[]", buf));
g_assert (hb_feature_from_string ("abcd[1:3]", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1:3]", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1:3]", buf));
g_assert_true (0 == strcmp ("abcd[1:3]", buf));
g_assert (hb_feature_from_string ("abcd[1:2]=1", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1:2]=1", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1]", buf));
g_assert_true (0 == strcmp ("abcd[1]", buf));
g_assert (hb_feature_from_string ("abcd[1:4]=2", -1, &feature));
g_assert_true (hb_feature_from_string ("abcd[1:4]=2", -1, &feature));
hb_feature_to_string (&feature, buf, 100);
g_assert (0 == strcmp ("abcd[1:4]=2", buf));
g_assert_true (0 == strcmp ("abcd[1:4]=2", buf));
}
int

View file

@ -45,8 +45,8 @@
#include <functional>
#include <utility>
int
main ()
static void
test_smart_ptrs (void)
{
hb_buffer_t *b = hb_buffer_create ();
hb::shared_ptr<hb_buffer_t> 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_true (pb != pb.get_empty ());
g_assert_true (pb != pb2);
}
int
main (int argc, char **argv)
{
hb_test_init (&argc, &argv);
hb_test_add (test_smart_ptrs);
return hb_test_run ();
}

View file

@ -1065,9 +1065,9 @@ static void
test_hb_draw_immutable (void)
{
hb_draw_funcs_t *draw_funcs = hb_draw_funcs_create ();
g_assert (!hb_draw_funcs_is_immutable (draw_funcs));
g_assert_true (!hb_draw_funcs_is_immutable (draw_funcs));
hb_draw_funcs_make_immutable (draw_funcs);
g_assert (hb_draw_funcs_is_immutable (draw_funcs));
g_assert_true (hb_draw_funcs_is_immutable (draw_funcs));
hb_draw_funcs_destroy (draw_funcs);
}
@ -1084,7 +1084,7 @@ test_hb_draw_funcs (const void* user_data)
hb_face_t *face = hb_test_open_font_file ("fonts/glyphs.ttf");
hb_font_t *font = hb_font_create (face);
hb_bool_t ret = hb_font_set_funcs_using (font, font_funcs_name);
g_assert (ret);
g_assert_true (ret);
hb_face_destroy (face);
{
draw_data.consumed = 0;
@ -1098,7 +1098,7 @@ test_hb_draw_funcs (const void* user_data)
hb_face_t *face = hb_test_open_font_file ("fonts/cff1_flex.otf");
hb_font_t *font = hb_font_create (face);
hb_bool_t ret = hb_font_set_funcs_using (font, font_funcs_name);
g_assert (ret);
g_assert_true (ret);
hb_face_destroy (face);
draw_data.consumed = 0;
@ -1141,7 +1141,7 @@ test_hb_draw_compare_ot_funcs (const void *user_data)
draw_data.str[draw_data.consumed] = '\0';
hb_bool_t ret = hb_font_set_funcs_using (font, font_funcs_name);
g_assert (ret);
g_assert_true (ret);
hb_font_draw_glyph (font, 1, funcs, &draw_data2);
draw_data2.str[draw_data2.consumed] = '\0';

View file

@ -88,7 +88,7 @@ main (int argc, char **argv)
master_face = hb_test_open_font_file_with_index (font_file, face_index);
master_head = hb_face_reference_table (master_face, HEAD_TAG);
g_assert (hb_blob_get_length (master_head) > 0);
g_assert_true (hb_blob_get_length (master_head) > 0);
font_file = hb_test_resolve_path (font_file);

View file

@ -38,15 +38,15 @@ test_face_empty (void)
hb_face_t *created_from_empty;
hb_face_t *created_from_null;
g_assert (hb_face_get_empty ());
g_assert_true (hb_face_get_empty ());
created_from_empty = hb_face_create (hb_blob_get_empty (), 0);
g_assert (hb_face_get_empty () != created_from_empty);
g_assert_true (hb_face_get_empty () != created_from_empty);
created_from_null = hb_face_create (NULL, 0);
g_assert (hb_face_get_empty () != created_from_null);
g_assert_true (hb_face_get_empty () != created_from_null);
g_assert (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
g_assert_true (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
g_assert_cmpint (hb_face_get_upem (hb_face_get_empty ()), ==, 1000);
@ -64,7 +64,7 @@ test_face_create (void)
face = hb_face_create (blob, 0);
hb_blob_destroy (blob);
g_assert (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
g_assert_true (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
g_assert_cmpint (hb_face_get_upem (face), ==, 1000);
@ -77,7 +77,7 @@ free_up (void *user_data)
{
int *freed = (int *) user_data;
g_assert (!*freed);
g_assert_true (!*freed);
(*freed)++;
}
@ -109,22 +109,22 @@ test_face_createfortables (void)
int freed = 0;
face = hb_face_create_for_tables (get_table, &freed, free_up);
g_assert (!freed);
g_assert_true (!freed);
g_assert (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
g_assert_true (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
blob = hb_face_reference_table (face, HB_TAG ('a','b','c','d'));
g_assert (blob != hb_blob_get_empty ());
g_assert_true (blob != hb_blob_get_empty ());
data = hb_blob_get_data (blob, &len);
g_assert_cmpint (len, ==, sizeof (test_data));
g_assert (0 == memcmp (data, test_data, sizeof (test_data)));
g_assert_true (0 == memcmp (data, test_data, sizeof (test_data)));
hb_blob_destroy (blob);
g_assert_cmpint (hb_face_get_upem (face), ==, 1000);
hb_face_destroy (face);
g_assert (freed);
g_assert_true (freed);
}
static unsigned int
@ -176,17 +176,17 @@ test_face_referenceblob (void)
blob = hb_face_reference_blob (face);
hb_face_destroy (face);
g_assert (blob != hb_blob_get_empty ());
g_assert_true (blob != hb_blob_get_empty ());
face = hb_face_create (blob, 0);
hb_blob_destroy (blob);
g_assert (face != hb_face_get_empty ());
g_assert_true (face != hb_face_get_empty ());
g_assert_cmpuint (hb_face_get_table_tags (face, 0, NULL, NULL), ==, sizeof (test_tags) / sizeof (test_tags[0]));
for (unsigned i = 0; i < sizeof (test_tags) / sizeof (test_tags[0]); i++)
{
hb_blob_t* table = hb_face_reference_table (face, test_tags[i]);
g_assert (table != hb_blob_get_empty ());
g_assert_true (table != hb_blob_get_empty ());
hb_blob_destroy (table);
}
@ -202,7 +202,7 @@ _test_font_nil_funcs (hb_font_t *font)
unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
x = y = 13;
g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
g_assert_true (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
@ -218,7 +218,7 @@ _test_font_nil_funcs (hb_font_t *font)
g_assert_cmpint (extents.height, ==, 0);
glyph = 3;
g_assert (!hb_font_get_glyph (font, 17, 2, &glyph));
g_assert_true (!hb_font_get_glyph (font, 17, 2, &glyph));
g_assert_cmpint (glyph, ==, 0);
}
@ -234,10 +234,10 @@ _test_fontfuncs_nil (hb_font_funcs_t *ffuncs)
blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
face = hb_face_create (blob, 0);
hb_blob_destroy (blob);
g_assert (!hb_face_is_immutable (face));
g_assert_true (!hb_face_is_immutable (face));
font = hb_font_create (face);
g_assert (font);
g_assert (hb_face_is_immutable (face));
g_assert_true (font);
g_assert_true (hb_face_is_immutable (face));
hb_face_destroy (face);
@ -247,7 +247,7 @@ _test_fontfuncs_nil (hb_font_funcs_t *ffuncs)
_test_font_nil_funcs (font);
subfont = hb_font_create_sub_font (font);
g_assert (subfont);
g_assert_true (subfont);
g_assert_cmpint (freed, ==, 0);
hb_font_destroy (font);
@ -262,8 +262,8 @@ _test_fontfuncs_nil (hb_font_funcs_t *ffuncs)
static void
test_fontfuncs_empty (void)
{
g_assert (hb_font_funcs_get_empty ());
g_assert (hb_font_funcs_is_immutable (hb_font_funcs_get_empty ()));
g_assert_true (hb_font_funcs_get_empty ());
g_assert_true (hb_font_funcs_is_immutable (hb_font_funcs_get_empty ()));
_test_fontfuncs_nil (hb_font_funcs_get_empty ());
}
@ -274,7 +274,7 @@ test_fontfuncs_nil (void)
ffuncs = hb_font_funcs_create ();
g_assert (!hb_font_funcs_is_immutable (ffuncs));
g_assert_true (!hb_font_funcs_is_immutable (ffuncs));
_test_fontfuncs_nil (hb_font_funcs_get_empty ());
hb_font_funcs_destroy (ffuncs);
@ -358,13 +358,13 @@ test_fontfuncs_subclassing (void)
hb_font_funcs_destroy (ffuncs1);
x = y = 1;
g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert_true (hb_font_get_glyph_contour_point_for_origin (font1, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 2);
g_assert_cmpint (y, ==, 3);
g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert_true (hb_font_get_glyph_contour_point_for_origin (font1, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 4);
g_assert_cmpint (y, ==, 5);
g_assert (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y));
g_assert_true (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
x = hb_font_get_glyph_h_advance (font1, 1);
@ -377,13 +377,13 @@ test_fontfuncs_subclassing (void)
*/
font2 = hb_font_create_sub_font (font1);
font3 = hb_font_create_sub_font (font2);
g_assert (!hb_font_is_immutable (font1));
g_assert (!hb_font_is_immutable (font2));
g_assert (!hb_font_is_immutable (font3));
g_assert_true (!hb_font_is_immutable (font1));
g_assert_true (!hb_font_is_immutable (font2));
g_assert_true (!hb_font_is_immutable (font3));
hb_font_make_immutable (font3);
g_assert (hb_font_is_immutable (font1));
g_assert (hb_font_is_immutable (font2));
g_assert (hb_font_is_immutable (font3));
g_assert_true (hb_font_is_immutable (font1));
g_assert_true (hb_font_is_immutable (font2));
g_assert_true (hb_font_is_immutable (font3));
hb_font_destroy (font2);
hb_font_destroy (font3);
@ -397,13 +397,13 @@ test_fontfuncs_subclassing (void)
hb_font_funcs_destroy (ffuncs2);
x = y = 1;
g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert_true (hb_font_get_glyph_contour_point_for_origin (font2, 1, 2, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 6);
g_assert_cmpint (y, ==, 7);
g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 2, 5, HB_DIRECTION_RTL, &x, &y));
g_assert_true (hb_font_get_glyph_contour_point_for_origin (font2, 2, 5, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 4);
g_assert_cmpint (y, ==, 5);
g_assert (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_true (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
x = hb_font_get_glyph_h_advance (font2, 1);
@ -416,13 +416,13 @@ test_fontfuncs_subclassing (void)
hb_font_set_scale (font3, 20, 30);
x = y = 1;
g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 1, 2, HB_DIRECTION_RTL, &x, &y));
g_assert_true (hb_font_get_glyph_contour_point_for_origin (font3, 1, 2, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 6*2);
g_assert_cmpint (y, ==, 7*3);
g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert_true (hb_font_get_glyph_contour_point_for_origin (font3, 2, 5, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 4*2);
g_assert_cmpint (y, ==, 5*3);
g_assert (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_true (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 0*2);
g_assert_cmpint (y, ==, 0*3);
x = hb_font_get_glyph_h_advance (font3, 1);
@ -508,21 +508,21 @@ test_font_empty (void)
hb_font_t *created_from_null;
hb_font_t *created_sub_from_null;
g_assert (hb_font_get_empty ());
g_assert_true (hb_font_get_empty ());
created_from_empty = hb_font_create (hb_face_get_empty ());
g_assert (hb_font_get_empty () != created_from_empty);
g_assert_true (hb_font_get_empty () != created_from_empty);
created_from_null = hb_font_create (NULL);
g_assert (hb_font_get_empty () != created_from_null);
g_assert_true (hb_font_get_empty () != created_from_null);
created_sub_from_null = hb_font_create_sub_font (NULL);
g_assert (hb_font_get_empty () != created_sub_from_null);
g_assert_true (hb_font_get_empty () != created_sub_from_null);
g_assert (hb_font_is_immutable (hb_font_get_empty ()));
g_assert_true (hb_font_is_immutable (hb_font_get_empty ()));
g_assert (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ());
g_assert (hb_font_get_parent (hb_font_get_empty ()) == NULL);
g_assert_true (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ());
g_assert_true (hb_font_get_parent (hb_font_get_empty ()) == NULL);
hb_font_destroy (created_sub_from_null);
hb_font_destroy (created_from_null);
@ -547,19 +547,19 @@ test_font_properties (void)
hb_face_destroy (face);
g_assert (hb_font_get_face (font) == face);
g_assert (hb_font_get_parent (font) == hb_font_get_empty ());
g_assert_true (hb_font_get_face (font) == face);
g_assert_true (hb_font_get_parent (font) == hb_font_get_empty ());
subfont = hb_font_create_sub_font (font);
g_assert (hb_font_get_parent (subfont) == font);
g_assert_true (hb_font_get_parent (subfont) == font);
hb_font_set_parent(subfont, NULL);
g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
g_assert_true (hb_font_get_parent (subfont) == hb_font_get_empty());
hb_font_set_parent(subfont, font);
g_assert (hb_font_get_parent (subfont) == font);
g_assert_true (hb_font_get_parent (subfont) == font);
hb_font_set_parent(subfont, NULL);
hb_font_make_immutable (subfont);
g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
g_assert_true (hb_font_get_parent (subfont) == hb_font_get_empty());
hb_font_set_parent(subfont, font);
g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
g_assert_true (hb_font_get_parent (subfont) == hb_font_get_empty());
hb_font_destroy (subfont);
@ -615,9 +615,9 @@ test_font_properties (void)
/* Check immutable */
g_assert (!hb_font_is_immutable (font));
g_assert_true (!hb_font_is_immutable (font));
hb_font_make_immutable (font);
g_assert (hb_font_is_immutable (font));
g_assert_true (hb_font_is_immutable (font));
hb_font_set_scale (font, 10, 12);
x_scale = y_scale = 13;
@ -636,8 +636,8 @@ test_font_properties (void)
subfont = hb_font_create_sub_font (font);
hb_font_destroy (font);
g_assert (hb_font_get_parent (subfont) == font);
g_assert (hb_font_get_face (subfont) == face);
g_assert_true (hb_font_get_parent (subfont) == font);
g_assert_true (hb_font_get_face (subfont) == face);
/* scale */
x_scale = y_scale = 13;

View file

@ -54,8 +54,8 @@ test_instance_cff2 (void)
hb_set_destroy (codepoints);
hb_subset_test_check (expected, face_abc_subset, HB_TAG ('C','F','F', '2'));
g_assert (hb_face_reference_table (face_abc_subset, HB_TAG ('f', 'v', 'a', 'r'))
== hb_blob_get_empty ());
g_assert_true (hb_face_reference_table (face_abc_subset, HB_TAG ('f', 'v', 'a', 'r'))
== hb_blob_get_empty ());
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);

View file

@ -32,31 +32,31 @@ test_map_basic (void)
{
hb_map_t *empty = hb_map_get_empty ();
hb_map_t *m;
g_assert (hb_map_is_empty (empty));
g_assert (!hb_map_allocation_successful (empty));
g_assert_true (hb_map_is_empty (empty));
g_assert_true (!hb_map_allocation_successful (empty));
hb_map_destroy (empty);
m = hb_map_create ();
g_assert (hb_map_allocation_successful (m));
g_assert (hb_map_is_empty (m));
g_assert_true (hb_map_allocation_successful (m));
g_assert_true (hb_map_is_empty (m));
hb_map_set (m, 213, 223);
hb_map_set (m, 643, 675);
g_assert_cmpint (hb_map_get_population (m), ==, 2);
g_assert_cmpint (hb_map_get (m, 213), ==, 223);
g_assert (!hb_map_has (m, 123));
g_assert (hb_map_has (m, 213));
g_assert_true (!hb_map_has (m, 123));
g_assert_true (hb_map_has (m, 213));
hb_map_del (m, 213);
g_assert (!hb_map_has (m, 213));
g_assert_true (!hb_map_has (m, 213));
g_assert_cmpint (hb_map_get (m, 643), ==, 675);
hb_map_set (m, 237, 673);
g_assert (hb_map_has (m, 237));
g_assert_true (hb_map_has (m, 237));
hb_map_clear (m);
g_assert (!hb_map_has (m, 237));
g_assert (!hb_map_has (m, 643));
g_assert_true (!hb_map_has (m, 237));
g_assert_true (!hb_map_has (m, 643));
g_assert_cmpint (hb_map_get_population (m), ==, 0);
hb_map_destroy (m);
@ -96,8 +96,8 @@ test_map_refcount (void)
hb_map_destroy (m);
/* We copied its reference so it is still usable after one destroy */
g_assert (hb_map_has (m, 213));
g_assert (hb_map_has (m2, 213));
g_assert_true (hb_map_has (m, 213));
g_assert_true (hb_map_has (m2, 213));
hb_map_destroy (m2);

View file

@ -91,10 +91,11 @@ 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);
g_assert_true (ret);
int i;
pthread_t *threads = calloc (num_threads, sizeof (pthread_t));
@ -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;
}

View file

@ -195,7 +195,7 @@ static void free_up0 (void *p)
data_t *data = (data_t *) p;
g_assert_cmphex (data->value, ==, MAGIC0);
g_assert (!data->freed);
g_assert_true (!data->freed);
data->freed = TRUE;
}
@ -204,7 +204,7 @@ static void free_up1 (void *p)
data_t *data = (data_t *) p;
g_assert_cmphex (data->value, ==, MAGIC1);
g_assert (!data->freed);
g_assert_true (!data->freed);
data->freed = TRUE;
}
@ -219,7 +219,7 @@ static void free_deadlock_test (void *p)
{
deadlock_test_t *t = (deadlock_test_t *) p;
g_assert (NULL == t->klass->get_user_data (t->object, &t->key));
g_assert_true (NULL == t->klass->get_user_data (t->object, &t->key));
}
@ -242,73 +242,73 @@ test_object (void)
g_test_message ("->create()");
obj = o->create ();
g_assert (obj);
g_assert_true (obj);
g_assert (obj == o->reference (obj));
g_assert_true (obj == o->reference (obj));
o->destroy (obj);
if (o->is_immutable)
g_assert (!o->is_immutable (obj));
g_assert_true (!o->is_immutable (obj));
g_assert (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert (o->get_user_data (obj, &key[0]) == &data[0]);
g_assert_true (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert_true (o->get_user_data (obj, &key[0]) == &data[0]);
if (o->is_immutable) {
o->make_immutable (obj);
g_assert (o->is_immutable (obj));
g_assert_true (o->is_immutable (obj));
}
/* Should still work even if object is made immutable */
g_assert (o->set_user_data (obj, &key[1], &data[1], free_up1, TRUE));
g_assert (o->get_user_data (obj, &key[1]) == &data[1]);
g_assert_true (o->set_user_data (obj, &key[1], &data[1], free_up1, TRUE));
g_assert_true (o->get_user_data (obj, &key[1]) == &data[1]);
g_assert (!o->set_user_data (obj, NULL, &data[0], free_up0, TRUE));
g_assert (o->get_user_data (obj, &key[0]) == &data[0]);
g_assert (o->set_user_data (obj, &key[0], &data[1], NULL, TRUE));
g_assert (data[0].freed);
g_assert (o->get_user_data (obj, &key[0]) == &data[1]);
g_assert (!data[1].freed);
g_assert_true (!o->set_user_data (obj, NULL, &data[0], free_up0, TRUE));
g_assert_true (o->get_user_data (obj, &key[0]) == &data[0]);
g_assert_true (o->set_user_data (obj, &key[0], &data[1], NULL, TRUE));
g_assert_true (data[0].freed);
g_assert_true (o->get_user_data (obj, &key[0]) == &data[1]);
g_assert_true (!data[1].freed);
data[0].freed = FALSE;
g_assert (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert (!data[0].freed);
g_assert (o->set_user_data (obj, &key[0], NULL, NULL, TRUE));
g_assert (data[0].freed);
g_assert_true (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert_true (!data[0].freed);
g_assert_true (o->set_user_data (obj, &key[0], NULL, NULL, TRUE));
g_assert_true (data[0].freed);
data[0].freed = FALSE;
global_data = 0;
g_assert (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert (!o->set_user_data (obj, &key[0], &data[0], free_up0, FALSE));
g_assert_true (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert_true (!o->set_user_data (obj, &key[0], &data[0], free_up0, FALSE));
g_assert_cmpuint (global_data, ==, 0);
g_assert (o->set_user_data (obj, &key[0], NULL, global_free_up, TRUE));
g_assert_true (o->set_user_data (obj, &key[0], NULL, global_free_up, TRUE));
g_assert_cmpuint (global_data, ==, 0);
g_assert (o->set_user_data (obj, &key[0], NULL, NULL, TRUE));
g_assert_true (o->set_user_data (obj, &key[0], NULL, NULL, TRUE));
g_assert_cmpuint (global_data, ==, 1);
global_data = 0;
for (j = 2; j < 1000; j++)
g_assert (o->set_user_data (obj, &key[j], &data[j], global_free_up, TRUE));
g_assert_true (o->set_user_data (obj, &key[j], &data[j], global_free_up, TRUE));
for (j = 2; j < 1000; j++)
g_assert (o->get_user_data (obj, &key[j]) == &data[j]);
g_assert_true (o->get_user_data (obj, &key[j]) == &data[j]);
for (j = 100; j < 1000; j++)
g_assert (o->set_user_data (obj, &key[j], NULL, NULL, TRUE));
g_assert_true (o->set_user_data (obj, &key[j], NULL, NULL, TRUE));
for (j = 2; j < 100; j++)
g_assert (o->get_user_data (obj, &key[j]) == &data[j]);
g_assert_true (o->get_user_data (obj, &key[j]) == &data[j]);
for (j = 100; j < 1000; j++)
g_assert (!o->get_user_data (obj, &key[j]));
g_assert_true (!o->get_user_data (obj, &key[j]));
g_assert_cmpuint (global_data, ==, 900);
/* Test set_user_data where the destroy() func calls user_data functions.
* Make sure it doesn't deadlock or corrupt memory. */
deadlock_test.klass = o;
deadlock_test.object = obj;
g_assert (o->set_user_data (obj, &deadlock_test.key, &deadlock_test, free_deadlock_test, TRUE));
g_assert (o->set_user_data (obj, &deadlock_test.key, NULL, NULL, TRUE));
g_assert_true (o->set_user_data (obj, &deadlock_test.key, &deadlock_test, free_deadlock_test, TRUE));
g_assert_true (o->set_user_data (obj, &deadlock_test.key, NULL, NULL, TRUE));
g_assert (!data[1].freed);
g_assert_true (!data[1].freed);
o->destroy (obj);
g_assert (data[0].freed);
g_assert (data[1].freed);
g_assert_true (data[0].freed);
g_assert_true (data[1].freed);
g_assert_cmpuint (global_data, ==, 1000-2);
}
@ -317,16 +317,16 @@ test_object (void)
g_test_message ("->get_empty()");
obj = o->get_empty ();
g_assert (obj);
g_assert_true (obj);
g_assert (obj == o->reference (obj));
g_assert_true (obj == o->reference (obj));
o->destroy (obj);
if (o->is_immutable)
g_assert (o->is_immutable (obj));
g_assert_true (o->is_immutable (obj));
g_assert (!o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert (!o->get_user_data (obj, &key[0]));
g_assert_true (!o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert_true (!o->get_user_data (obj, &key[0]));
o->destroy (obj);
o->destroy (obj);
@ -334,7 +334,7 @@ test_object (void)
o->destroy (obj);
o->destroy (obj);
g_assert (!data[0].freed);
g_assert_true (!data[0].freed);
}
{
@ -347,18 +347,18 @@ test_object (void)
if (obj == o->get_empty ())
continue; /* Tested already */
g_assert (obj == o->reference (obj));
g_assert_true (obj == o->reference (obj));
o->destroy (obj);
if (o->is_immutable)
g_assert (!o->is_immutable (obj));
g_assert_true (!o->is_immutable (obj));
g_assert (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert (o->get_user_data (obj, &key[0]));
g_assert_true (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
g_assert_true (o->get_user_data (obj, &key[0]));
o->destroy (obj);
g_assert (data[0].freed);
g_assert_true (data[0].freed);
}
}
}

View file

@ -52,12 +52,12 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (0, ==, hb_set_get_population (before));
g_assert_cmpuint (684, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (54, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (372, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (574, ==, g);
END();
@ -67,14 +67,14 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (143, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (2, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (319, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (519, ==, g);
END();
@ -84,14 +84,14 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (10, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (92, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (9, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (6, ==, g);
END();
@ -101,14 +101,14 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (14, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (1823, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (22, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (1897, ==, g);
END();
@ -118,19 +118,19 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (10, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (92, ==, g);
g_assert_cmpuint (2, ==, hb_set_get_population (after));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (after, &g));
g_assert_true (hb_set_next (after, &g));
g_assert_cmpuint (1826, ==, g);
g_assert (hb_set_next (after, &g));
g_assert_true (hb_set_next (after, &g));
g_assert_cmpuint (1837, ==, g);
g_assert_cmpuint (9, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (6, ==, g);
END();
@ -138,19 +138,19 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
BEGIN(HB_OT_TAG_GSUB, 13);
g_assert_cmpuint (771, ==, hb_set_get_population (before));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (before, &g));
g_assert_true (hb_set_next (before, &g));
g_assert_cmpuint (2, ==, g);
g_assert_cmpuint (28, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (1823, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (48, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (325, ==, g);
END();
@ -160,7 +160,7 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (179, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (28, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -173,7 +173,7 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (48, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (1823, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -186,7 +186,7 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (1426, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (2, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -202,7 +202,7 @@ test_ot_layout_lookup_collect_glyphs_source_sans (void)
g_assert_cmpuint (1, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (4, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -233,22 +233,22 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
g_assert_cmpuint (3, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (228, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (416, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (441, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (3, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (267, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (268, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (279, ==, g);
END();
@ -258,22 +258,22 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
g_assert_cmpuint (3, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (228, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (416, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (441, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (3, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (267, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (268, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (279, ==, g);
END();
@ -281,22 +281,22 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
BEGIN(HB_OT_TAG_GSUB, 16);
g_assert_cmpuint (16, ==, hb_set_get_population (before));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (before, &g));
g_assert_true (hb_set_next (before, &g));
g_assert_cmpuint (74, ==, g);
g_assert_cmpuint (27, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (276, ==, g);
g_assert_cmpuint (14, ==, hb_set_get_population (after));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (after, &g));
g_assert_true (hb_set_next (after, &g));
g_assert_cmpuint (252, ==, g);
g_assert_cmpuint (43, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (74, ==, g);
END();
@ -306,14 +306,14 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
g_assert_cmpuint (246, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (252, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (258, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (74, ==, g);
END();
@ -324,7 +324,7 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
g_assert_cmpuint (616, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (228, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -337,7 +337,7 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
g_assert_cmpuint (46, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (1004, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -350,7 +350,7 @@ test_ot_layout_lookup_collect_glyphs_noto_nastaliq (void)
g_assert_cmpuint (242, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (257, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
@ -381,26 +381,26 @@ test_ot_layout_lookup_collect_glyphs_qahiri (void)
g_assert_cmpuint (4, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (52, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (60, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (62, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (159, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (4, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (53, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (61, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (63, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (160, ==, g);
END();
@ -408,26 +408,26 @@ test_ot_layout_lookup_collect_glyphs_qahiri (void)
BEGIN(HB_OT_TAG_GSUB, 11);
g_assert_cmpuint (1, ==, hb_set_get_population (before));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (before, &g));
g_assert_true (hb_set_next (before, &g));
g_assert_cmpuint (39, ==, g);
g_assert_cmpuint (2, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (154, ==, g);
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (159, ==, g);
g_assert_cmpuint (1, ==, hb_set_get_population (after));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (after, &g));
g_assert_true (hb_set_next (after, &g));
g_assert_cmpuint (179, ==, g);
g_assert_cmpuint (2, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (155, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (162, ==, g);
END();
@ -437,20 +437,20 @@ test_ot_layout_lookup_collect_glyphs_qahiri (void)
g_assert_cmpuint (4, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (53, ==, g);
g_assert_cmpuint (0, ==, hb_set_get_population (after));
g_assert_cmpuint (4, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (52, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (60, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (62, ==, g);
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (159, ==, g);
END();
@ -460,17 +460,17 @@ test_ot_layout_lookup_collect_glyphs_qahiri (void)
g_assert_cmpuint (42, ==, hb_set_get_population (input));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (input, &g));
g_assert_true (hb_set_next (input, &g));
g_assert_cmpuint (47, ==, g);
g_assert_cmpuint (46, ==, hb_set_get_population (after));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (after, &g));
g_assert_true (hb_set_next (after, &g));
g_assert_cmpuint (61, ==, g);
g_assert_cmpuint (42, ==, hb_set_get_population (output));
g = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (output, &g));
g_assert_true (hb_set_next (output, &g));
g_assert_cmpuint (463, ==, g);
END();

View file

@ -348,58 +348,58 @@ test_hb_ot_color_glyph_get_layers (void)
static void
test_hb_ot_color_has_data (void)
{
g_assert (hb_ot_color_has_layers (empty) == FALSE);
g_assert (hb_ot_color_has_layers (cpal_v0) == TRUE);
g_assert (hb_ot_color_has_layers (cpal_v1) == TRUE);
g_assert (hb_ot_color_has_layers (cpal) == TRUE);
g_assert (hb_ot_color_has_layers (cbdt) == FALSE);
g_assert (hb_ot_color_has_layers (sbix) == FALSE);
g_assert (hb_ot_color_has_layers (svg) == FALSE);
g_assert (hb_ot_color_has_layers (colrv1) == FALSE);
g_assert_true (hb_ot_color_has_layers (empty) == FALSE);
g_assert_true (hb_ot_color_has_layers (cpal_v0) == TRUE);
g_assert_true (hb_ot_color_has_layers (cpal_v1) == TRUE);
g_assert_true (hb_ot_color_has_layers (cpal) == TRUE);
g_assert_true (hb_ot_color_has_layers (cbdt) == FALSE);
g_assert_true (hb_ot_color_has_layers (sbix) == FALSE);
g_assert_true (hb_ot_color_has_layers (svg) == FALSE);
g_assert_true (hb_ot_color_has_layers (colrv1) == FALSE);
g_assert (hb_ot_color_has_palettes (empty) == FALSE);
g_assert (hb_ot_color_has_palettes (cpal_v0) == TRUE);
g_assert (hb_ot_color_has_palettes (cpal_v1) == TRUE);
g_assert (hb_ot_color_has_palettes (cpal) == TRUE);
g_assert (hb_ot_color_has_palettes (cbdt) == FALSE);
g_assert (hb_ot_color_has_palettes (sbix) == FALSE);
g_assert (hb_ot_color_has_palettes (svg) == FALSE);
g_assert (hb_ot_color_has_palettes (colrv1) == TRUE);
g_assert_true (hb_ot_color_has_palettes (empty) == FALSE);
g_assert_true (hb_ot_color_has_palettes (cpal_v0) == TRUE);
g_assert_true (hb_ot_color_has_palettes (cpal_v1) == TRUE);
g_assert_true (hb_ot_color_has_palettes (cpal) == TRUE);
g_assert_true (hb_ot_color_has_palettes (cbdt) == FALSE);
g_assert_true (hb_ot_color_has_palettes (sbix) == FALSE);
g_assert_true (hb_ot_color_has_palettes (svg) == FALSE);
g_assert_true (hb_ot_color_has_palettes (colrv1) == TRUE);
g_assert (hb_ot_color_has_svg (empty) == FALSE);
g_assert (hb_ot_color_has_svg (cpal_v0) == FALSE);
g_assert (hb_ot_color_has_svg (cpal_v1) == FALSE);
g_assert (hb_ot_color_has_svg (cpal) == FALSE);
g_assert (hb_ot_color_has_svg (cbdt) == FALSE);
g_assert (hb_ot_color_has_svg (sbix) == FALSE);
g_assert (hb_ot_color_has_svg (svg) == TRUE);
g_assert (hb_ot_color_has_svg (colrv1) == FALSE);
g_assert_true (hb_ot_color_has_svg (empty) == FALSE);
g_assert_true (hb_ot_color_has_svg (cpal_v0) == FALSE);
g_assert_true (hb_ot_color_has_svg (cpal_v1) == FALSE);
g_assert_true (hb_ot_color_has_svg (cpal) == FALSE);
g_assert_true (hb_ot_color_has_svg (cbdt) == FALSE);
g_assert_true (hb_ot_color_has_svg (sbix) == FALSE);
g_assert_true (hb_ot_color_has_svg (svg) == TRUE);
g_assert_true (hb_ot_color_has_svg (colrv1) == FALSE);
g_assert (hb_ot_color_has_png (empty) == FALSE);
g_assert (hb_ot_color_has_png (cpal_v0) == FALSE);
g_assert (hb_ot_color_has_png (cpal_v1) == FALSE);
g_assert (hb_ot_color_has_png (cpal) == FALSE);
g_assert (hb_ot_color_has_png (cbdt) == TRUE);
g_assert (hb_ot_color_has_png (sbix) == TRUE);
g_assert (hb_ot_color_has_png (svg) == FALSE);
g_assert (hb_ot_color_has_png (colrv1) == FALSE);
g_assert_true (hb_ot_color_has_png (empty) == FALSE);
g_assert_true (hb_ot_color_has_png (cpal_v0) == FALSE);
g_assert_true (hb_ot_color_has_png (cpal_v1) == FALSE);
g_assert_true (hb_ot_color_has_png (cpal) == FALSE);
g_assert_true (hb_ot_color_has_png (cbdt) == TRUE);
g_assert_true (hb_ot_color_has_png (sbix) == TRUE);
g_assert_true (hb_ot_color_has_png (svg) == FALSE);
g_assert_true (hb_ot_color_has_png (colrv1) == FALSE);
g_assert (hb_ot_color_has_paint (empty) == FALSE);
g_assert (hb_ot_color_has_paint (cpal_v0) == FALSE);
g_assert (hb_ot_color_has_paint (cpal_v1) == FALSE);
g_assert (hb_ot_color_has_paint (cpal) == FALSE);
g_assert (hb_ot_color_has_paint (cbdt) == FALSE);
g_assert (hb_ot_color_has_paint (sbix) == FALSE);
g_assert (hb_ot_color_has_paint (svg) == FALSE);
g_assert (hb_ot_color_has_paint (colrv1) == TRUE);
g_assert_true (hb_ot_color_has_paint (empty) == FALSE);
g_assert_true (hb_ot_color_has_paint (cpal_v0) == FALSE);
g_assert_true (hb_ot_color_has_paint (cpal_v1) == FALSE);
g_assert_true (hb_ot_color_has_paint (cpal) == FALSE);
g_assert_true (hb_ot_color_has_paint (cbdt) == FALSE);
g_assert_true (hb_ot_color_has_paint (sbix) == FALSE);
g_assert_true (hb_ot_color_has_paint (svg) == FALSE);
g_assert_true (hb_ot_color_has_paint (colrv1) == TRUE);
}
static void
test_hb_ot_color_glyph_has_paint (void)
{
g_assert (hb_ot_color_has_paint (colrv1));
g_assert (hb_ot_color_glyph_has_paint (colrv1, 10));
g_assert (!hb_ot_color_glyph_has_paint (colrv1, 20));
g_assert_true (hb_ot_color_has_paint (colrv1));
g_assert_true (hb_ot_color_glyph_has_paint (colrv1, 10));
g_assert_true (!hb_ot_color_glyph_has_paint (colrv1, 20));
}
static void
@ -410,17 +410,17 @@ test_hb_ot_color_svg (void)
const char *data;
blob = hb_ot_color_glyph_reference_svg (svg, 0);
g_assert (hb_blob_get_length (blob) == 0);
g_assert_true (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_svg (svg, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 146);
g_assert (strncmp (data, "<?xml", 4) == 0);
g_assert (strncmp (data + 140, "</svg>", 5) == 0);
g_assert_true (strncmp (data, "<?xml", 4) == 0);
g_assert_true (strncmp (data + 140, "</svg>", 5) == 0);
hb_blob_destroy (blob);
blob = hb_ot_color_glyph_reference_svg (empty, 0);
g_assert (hb_blob_get_length (blob) == 0);
g_assert_true (hb_blob_get_length (blob) == 0);
}
@ -442,12 +442,12 @@ test_hb_ot_color_png (void)
g_assert_cmpint (extents.y_bearing, ==, 0);
g_assert_cmpint (extents.width, ==, 0);
g_assert_cmpint (extents.height, ==, 0);
g_assert (hb_blob_get_length (blob) == 0);
g_assert_true (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_png (sbix_font, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 224);
g_assert (strncmp (data + 1, "PNG", 3) == 0);
g_assert_true (strncmp (data + 1, "PNG", 3) == 0);
hb_font_get_glyph_extents (sbix_font, 1, &extents);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 800);
@ -459,12 +459,12 @@ test_hb_ot_color_png (void)
/* cbdt */
cbdt_font = hb_font_create (cbdt);
blob = hb_ot_color_glyph_reference_png (cbdt_font, 0);
g_assert (hb_blob_get_length (blob) == 0);
g_assert_true (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_png (cbdt_font, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 88);
g_assert (strncmp (data + 1, "PNG", 3) == 0);
g_assert_true (strncmp (data + 1, "PNG", 3) == 0);
hb_font_get_glyph_extents (cbdt_font, 1, &extents);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 1024);

View file

@ -33,14 +33,14 @@ static void
test_extents_cff1 (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansPro-Regular.abc.otf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 1, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 52);
g_assert_cmpint (extents.y_bearing, ==, 498);
@ -50,13 +50,13 @@ test_extents_cff1 (void)
hb_font_destroy (font);
hb_face_t *face_j = hb_test_open_font_file ("fonts/SourceHanSans-Regular.41,3041,4C2E.otf");
g_assert (face_j);
g_assert_true (face_j);
hb_font_t *font_j = hb_font_create (face_j);
hb_face_destroy (face_j);
g_assert (font_j);
g_assert_true (font_j);
hb_bool_t result_j = hb_font_get_glyph_extents (font_j, 3, &extents);
g_assert (result_j);
g_assert_true (result_j);
g_assert_cmpint (extents.x_bearing, ==, 34);
g_assert_cmpint (extents.y_bearing, ==, 840);
@ -70,14 +70,14 @@ static void
test_extents_cff1_flex (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/cff1_flex.otf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 1, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, -20);
g_assert_cmpint (extents.y_bearing, ==, 520);
@ -91,14 +91,14 @@ static void
test_extents_cff1_seac (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/cff1_seac.otf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 3, &extents); /* Agrave */
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 3);
g_assert_cmpint (extents.y_bearing, ==, 861);
@ -106,7 +106,7 @@ test_extents_cff1_seac (void)
g_assert_cmpint (extents.height, ==, -861);
result = hb_font_get_glyph_extents (font, 4, &extents); /* Udieresis */
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 87);
g_assert_cmpint (extents.y_bearing, ==, 827);
@ -120,14 +120,14 @@ static void
test_extents_cff2 (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/AdobeVFPrototype.abc.otf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 1, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 46);
g_assert_cmpint (extents.y_bearing, ==, 487);
@ -137,7 +137,7 @@ test_extents_cff2 (void)
float coords[2] = { 600.0f, 50.0f };
hb_font_set_var_coords_design (font, coords, 2);
result = hb_font_get_glyph_extents (font, 1, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 38);
g_assert_cmpint (extents.y_bearing, ==, 493);
@ -151,16 +151,16 @@ static void
test_extents_cff2_vsindex (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/AdobeVFPrototype_vsindex.otf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
float coords[2] = { 800.0f, 50.0f };
hb_font_set_var_coords_design (font, coords, 2);
hb_bool_t result = hb_font_get_glyph_extents (font, 1, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 12);
g_assert_cmpint (extents.y_bearing, ==, 655);
@ -168,7 +168,7 @@ test_extents_cff2_vsindex (void)
g_assert_cmpint (extents.height, ==, -655);
result = hb_font_get_glyph_extents (font, 2, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 8);
g_assert_cmpint (extents.y_bearing, ==, 669);
@ -182,15 +182,15 @@ static void
test_extents_cff2_vsindex_named_instance (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/AdobeVFPrototype_vsindex.otf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_font_set_var_named_instance (font, 6); // 6 (BlackMediumContrast): 900, 50
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 1, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 13);
g_assert_cmpint (extents.y_bearing, ==, 652);
@ -198,7 +198,7 @@ test_extents_cff2_vsindex_named_instance (void)
g_assert_cmpint (extents.height, ==, -652);
result = hb_font_get_glyph_extents (font, 2, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 6);
g_assert_cmpint (extents.y_bearing, ==, 675);

View file

@ -209,7 +209,7 @@ static void
test_ot_var_axis_on_zero_named_instance (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/Zycon.ttf");
g_assert (hb_ot_var_get_axis_count (face));
g_assert_true (hb_ot_var_get_axis_count (face));
hb_face_destroy (face);
}

View file

@ -33,9 +33,9 @@ test_one_glyph (hb_font_t *font, hb_codepoint_t gid, const char *name)
char buf[64];
hb_codepoint_t glyph;
g_assert(hb_font_get_glyph_name (font, gid, buf, sizeof (buf)));
g_assert_true(hb_font_get_glyph_name (font, gid, buf, sizeof (buf)));
g_assert_cmpstr(buf, ==, name);
g_assert(hb_font_get_glyph_from_name (font, name, -1, &glyph));
g_assert_true(hb_font_get_glyph_from_name (font, name, -1, &glyph));
g_assert_cmpint(glyph, ==, gid);
}

View file

@ -74,18 +74,18 @@ test_ot_layout_table_find_script (void)
hb_face_t *face = hb_test_open_font_file ("fonts/NotoNastaliqUrdu-Regular.ttf");
unsigned int index;
g_assert (hb_ot_layout_table_find_script (face, HB_OT_TAG_GSUB, HB_TAG ('a','r','a','b'), &index));
g_assert_true (hb_ot_layout_table_find_script (face, HB_OT_TAG_GSUB, HB_TAG ('a','r','a','b'), &index));
g_assert_cmpuint (0, ==, index);
g_assert (hb_ot_layout_table_find_script (face, HB_OT_TAG_GSUB, HB_TAG ('d','f','l','t'), &index));
g_assert_true (hb_ot_layout_table_find_script (face, HB_OT_TAG_GSUB, HB_TAG ('d','f','l','t'), &index));
g_assert_cmpuint (1, ==, index);
g_assert (hb_ot_layout_table_find_script (face, HB_OT_TAG_GSUB, HB_TAG ('l','a','t','n'), &index));
g_assert_true (hb_ot_layout_table_find_script (face, HB_OT_TAG_GSUB, HB_TAG ('l','a','t','n'), &index));
g_assert_cmpuint (2, ==, index);
g_assert (hb_ot_layout_table_find_script (face, HB_OT_TAG_GPOS, HB_TAG ('a','r','a','b'), &index));
g_assert_true (hb_ot_layout_table_find_script (face, HB_OT_TAG_GPOS, HB_TAG ('a','r','a','b'), &index));
g_assert_cmpuint (0, ==, index);
g_assert (!hb_ot_layout_table_find_script (face, HB_OT_TAG_GPOS, HB_TAG ('d','f','l','t'), &index));
g_assert_true (!hb_ot_layout_table_find_script (face, HB_OT_TAG_GPOS, HB_TAG ('d','f','l','t'), &index));
g_assert_cmpuint (0xFFFF, ==, index);
g_assert (!hb_ot_layout_table_find_script (face, HB_OT_TAG_GPOS, HB_TAG ('l','a','t','n'), &index));
g_assert_true (!hb_ot_layout_table_find_script (face, HB_OT_TAG_GPOS, HB_TAG ('l','a','t','n'), &index));
g_assert_cmpuint (0xFFFF, ==, index);
hb_face_destroy (face);

View file

@ -38,22 +38,22 @@ test_has_data (void)
hb_font_t *font;
face = hb_test_open_font_file ("fonts/MathTestFontNone.otf");
g_assert (!hb_ot_math_has_data (face)); // MATH table not available
g_assert_true (!hb_ot_math_has_data (face)); // MATH table not available
hb_face_destroy (face);
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
g_assert (hb_ot_math_has_data (face)); // MATH table available
g_assert_true (hb_ot_math_has_data (face)); // MATH table available
hb_face_destroy (face);
face = hb_face_get_empty ();
font = hb_font_create (face);
g_assert (!hb_ot_math_has_data (face)); // MATH table not available
g_assert_true (!hb_ot_math_has_data (face)); // MATH table not available
hb_font_destroy (font);
hb_face_destroy (face);
font = hb_font_get_empty ();
face = hb_font_get_face (font);
g_assert (!hb_ot_math_has_data (face)); // MATH table not available
g_assert_true (!hb_ot_math_has_data (face)); // MATH table not available
hb_font_destroy (font);
hb_face_destroy (face);
}
@ -155,21 +155,21 @@ test_get_glyph_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 0); // MathGlyphInfo not available
hb_font_destroy (font);
hb_face_destroy (face);
face = hb_test_open_font_file ("fonts/MathTestFontPartial1.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 0); // MathGlyphInfo empty
hb_font_destroy (font);
hb_face_destroy (face);
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 0); // MathItalicsCorrectionInfo empty
hb_font_destroy (font);
hb_face_destroy (face);
@ -177,13 +177,13 @@ test_get_glyph_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontFull.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 0); // Glyph without italic correction.
g_assert (hb_font_get_glyph_from_name (font, "A", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "A", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 394);
g_assert (hb_font_get_glyph_from_name (font, "B", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "B", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 300);
g_assert (hb_font_get_glyph_from_name (font, "C", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "C", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_italics_correction (font, glyph), ==, 904);
hb_font_destroy (font);
hb_face_destroy (face);
@ -199,7 +199,7 @@ test_get_glyph_top_accent_attachment (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 1000); // MathGlyphInfo not available
hb_font_destroy (font);
hb_face_destroy (face);
@ -207,7 +207,7 @@ test_get_glyph_top_accent_attachment (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial1.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 1000); // MathGlyphInfo empty
hb_font_destroy (font);
hb_face_destroy (face);
@ -215,7 +215,7 @@ test_get_glyph_top_accent_attachment (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 1000); // MathTopAccentAttachment empty
hb_font_destroy (font);
hb_face_destroy (face);
@ -223,13 +223,13 @@ test_get_glyph_top_accent_attachment (void)
face = hb_test_open_font_file ("fonts/MathTestFontFull.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 1000); // Glyph without top accent attachment.
g_assert (hb_font_get_glyph_from_name (font, "D", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "D", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 748);
g_assert (hb_font_get_glyph_from_name (font, "E", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "E", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 692);
g_assert (hb_font_get_glyph_from_name (font, "F", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "F", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_top_accent_attachment (font, glyph), ==, 636);
hb_font_destroy (font);
hb_face_destroy (face);
@ -244,24 +244,24 @@ test_is_glyph_extended_shape (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert (!hb_ot_math_is_glyph_extended_shape (face, glyph)); // MathGlyphInfo not available
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (!hb_ot_math_is_glyph_extended_shape (face, glyph)); // MathGlyphInfo not available
hb_font_destroy (font);
hb_face_destroy (face);
face = hb_test_open_font_file ("fonts/MathTestFontPartial1.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert (!hb_ot_math_is_glyph_extended_shape (face, glyph)); // MathGlyphInfo empty
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (!hb_ot_math_is_glyph_extended_shape (face, glyph)); // MathGlyphInfo empty
hb_font_destroy (font);
hb_face_destroy (face);
face = hb_test_open_font_file ("fonts/MathTestFontFull.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "G", -1, &glyph));
g_assert (!hb_ot_math_is_glyph_extended_shape (face, glyph));
g_assert (hb_font_get_glyph_from_name (font, "H", -1, &glyph));
g_assert (hb_ot_math_is_glyph_extended_shape (face, glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "G", -1, &glyph));
g_assert_true (!hb_ot_math_is_glyph_extended_shape (face, glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "H", -1, &glyph));
g_assert_true (hb_ot_math_is_glyph_extended_shape (face, glyph));
hb_font_destroy (font);
hb_face_destroy (face);
}
@ -275,7 +275,7 @@ test_get_glyph_kerning (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathGlyphInfo not available
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathGlyphInfo not available
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathGlyphInfo not available
@ -285,7 +285,7 @@ test_get_glyph_kerning (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfo empty
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfo empty
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfo empty
@ -295,7 +295,7 @@ test_get_glyph_kerning (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial3.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfoRecords empty
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
@ -306,7 +306,7 @@ test_get_glyph_kerning (void)
face = hb_test_open_font_file ("fonts/MathTestFontFull.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "I", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "I", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 7), ==, 62); // lower than min height
g_assert_cmpint (hb_ot_math_get_glyph_kerning (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 14), ==, 104); // equal to min height
@ -339,7 +339,7 @@ test_get_glyph_kernings (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0, NULL, NULL), ==, 0); // MathGlyphInfo not available
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0, NULL, NULL), ==, 0); // MathGlyphInfo not available
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0, NULL, NULL), ==, 0); // MathGlyphInfo not available
@ -349,7 +349,7 @@ test_get_glyph_kernings (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0, NULL, NULL), ==, 0); // MathKernInfo empty
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0, NULL, NULL), ==, 0); // MathKernInfo empty
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0, NULL, NULL), ==, 0); // MathKernInfo empty
@ -359,7 +359,7 @@ test_get_glyph_kernings (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial3.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0, NULL, NULL), ==, 0); // MathKernInfoRecords empty
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0, NULL, NULL), ==, 0); // MathKernInfoRecords empty
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0, NULL, NULL), ==, 0); // MathKernInfoRecords empty
@ -370,7 +370,7 @@ test_get_glyph_kernings (void)
face = hb_test_open_font_file ("fonts/MathTestFontFull.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "I", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "I", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0, NULL, NULL), ==, 10);
g_assert_cmpint (hb_ot_math_get_glyph_kernings (font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0, NULL, NULL), ==, 3);
@ -438,7 +438,7 @@ test_get_glyph_assembly_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 0); // MathVariants not available
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 0); // MathVariants not available
hb_font_destroy (font);
@ -446,7 +446,7 @@ test_get_glyph_assembly_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial1.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
hb_font_destroy (font);
@ -454,7 +454,7 @@ test_get_glyph_assembly_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
hb_font_destroy (font);
@ -462,7 +462,7 @@ test_get_glyph_assembly_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial3.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
hb_font_destroy (font);
@ -470,7 +470,7 @@ test_get_glyph_assembly_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial4.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 0);
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 0);
hb_font_destroy (font);
@ -479,10 +479,10 @@ test_get_glyph_assembly_italics_correction (void)
face = hb_test_open_font_file ("fonts/MathTestFontFull.otf");
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "arrowleft", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowleft", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 248);
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 0);
g_assert (hb_font_get_glyph_from_name (font, "arrowup", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowup", -1, &glyph));
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, TRUE), ==, 0);
g_assert_cmpint (get_glyph_assembly_italics_correction (font, glyph, FALSE), ==, 662);
hb_font_destroy (font);
@ -524,7 +524,7 @@ test_get_glyph_variants (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -532,7 +532,7 @@ test_get_glyph_variants (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial1.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -540,7 +540,7 @@ test_get_glyph_variants (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -548,7 +548,7 @@ test_get_glyph_variants (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial3.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -556,7 +556,7 @@ test_get_glyph_variants (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial4.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_variants (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -566,7 +566,7 @@ test_get_glyph_variants (void)
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "arrowleft", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowleft", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font,
glyph,
HB_DIRECTION_BTT,
@ -580,7 +580,7 @@ test_get_glyph_variants (void)
NULL,
NULL), ==, 3);
g_assert (hb_font_get_glyph_from_name (font, "arrowup", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowup", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_variants (font,
glyph,
HB_DIRECTION_BTT,
@ -594,7 +594,7 @@ test_get_glyph_variants (void)
NULL,
NULL), ==, 0);
g_assert (hb_font_get_glyph_from_name (font, "arrowleft", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowleft", -1, &glyph));
do {
count = variantsSize;
hb_ot_math_get_glyph_variants (font,
@ -606,17 +606,17 @@ test_get_glyph_variants (void)
offset += count;
} while (count == variantsSize);
g_assert_cmpint (offset, ==, 3);
g_assert (hb_font_get_glyph_from_name (font, "uni2190_size2", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2190_size2", -1, &glyph));
g_assert_cmpint (variants[0].glyph, ==, glyph);
g_assert_cmpint (variants[0].advance, ==, 4302);
g_assert (hb_font_get_glyph_from_name (font, "uni2190_size3", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2190_size3", -1, &glyph));
g_assert_cmpint (variants[1].glyph, ==, glyph);
g_assert_cmpint (variants[1].advance, ==, 4802);
g_assert (hb_font_get_glyph_from_name (font, "uni2190_size4", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2190_size4", -1, &glyph));
g_assert_cmpint (variants[2].glyph, ==, glyph);
g_assert_cmpint (variants[2].advance, ==, 5802);
g_assert (hb_font_get_glyph_from_name (font, "arrowup", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowup", -1, &glyph));
offset = 0;
do {
count = variantsSize;
@ -629,16 +629,16 @@ test_get_glyph_variants (void)
offset += count;
} while (count == variantsSize);
g_assert_cmpint (offset, ==, 4);
g_assert (hb_font_get_glyph_from_name (font, "uni2191_size2", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2191_size2", -1, &glyph));
g_assert_cmpint (variants[0].glyph, ==, glyph);
g_assert_cmpint (variants[0].advance, ==, 2251);
g_assert (hb_font_get_glyph_from_name (font, "uni2191_size3", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2191_size3", -1, &glyph));
g_assert_cmpint (variants[1].glyph, ==, glyph);
g_assert_cmpint (variants[1].advance, ==, 2501);
g_assert (hb_font_get_glyph_from_name (font, "uni2191_size4", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2191_size4", -1, &glyph));
g_assert_cmpint (variants[2].glyph, ==, glyph);
g_assert_cmpint (variants[2].advance, ==, 3001);
g_assert (hb_font_get_glyph_from_name (font, "uni2191_size5", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "uni2191_size5", -1, &glyph));
g_assert_cmpint (variants[3].glyph, ==, glyph);
g_assert_cmpint (variants[3].advance, ==, 3751);
@ -659,7 +659,7 @@ test_get_glyph_assembly (void)
face = hb_test_open_font_file ("fonts/MathTestFontEmpty.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -667,7 +667,7 @@ test_get_glyph_assembly (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial1.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -675,7 +675,7 @@ test_get_glyph_assembly (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial2.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -683,7 +683,7 @@ test_get_glyph_assembly (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial3.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -691,7 +691,7 @@ test_get_glyph_assembly (void)
face = hb_test_open_font_file ("fonts/MathTestFontPartial4.otf");
font = hb_font_create (face);
g_assert (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "space", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
hb_font_destroy (font);
@ -701,7 +701,7 @@ test_get_glyph_assembly (void)
font = hb_font_create (face);
hb_font_set_scale (font, 2000, 1000);
g_assert (hb_font_get_glyph_from_name (font, "arrowright", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowright", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font,
glyph,
HB_DIRECTION_BTT,
@ -717,7 +717,7 @@ test_get_glyph_assembly (void)
NULL,
NULL), ==, 3);
g_assert (hb_font_get_glyph_from_name (font, "arrowdown", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowdown", -1, &glyph));
g_assert_cmpint (hb_ot_math_get_glyph_assembly (font,
glyph,
HB_DIRECTION_BTT,
@ -733,7 +733,7 @@ test_get_glyph_assembly (void)
NULL,
NULL), ==, 0);
g_assert (hb_font_get_glyph_from_name (font, "arrowright", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowright", -1, &glyph));
do {
count = partsSize;
hb_ot_math_get_glyph_assembly (font,
@ -746,26 +746,26 @@ test_get_glyph_assembly (void)
offset += count;
} while (count == partsSize);
g_assert_cmpint (offset, ==, 3);
g_assert (hb_font_get_glyph_from_name (font, "left", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "left", -1, &glyph));
g_assert_cmpint (parts[0].glyph, ==, glyph);
g_assert_cmpint (parts[0].start_connector_length, ==, 800);
g_assert_cmpint (parts[0].end_connector_length, ==, 384);
g_assert_cmpint (parts[0].full_advance, ==, 2000);
g_assert (!(parts[0].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert (hb_font_get_glyph_from_name (font, "horizontal", -1, &glyph));
g_assert_true (!(parts[0].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert_true (hb_font_get_glyph_from_name (font, "horizontal", -1, &glyph));
g_assert_cmpint (parts[1].glyph, ==, glyph);
g_assert_cmpint (parts[1].start_connector_length, ==, 524);
g_assert_cmpint (parts[1].end_connector_length, ==, 800);
g_assert_cmpint (parts[1].full_advance, ==, 2000);
g_assert (parts[1].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER);
g_assert (hb_font_get_glyph_from_name (font, "right", -1, &glyph));
g_assert_true (parts[1].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER);
g_assert_true (hb_font_get_glyph_from_name (font, "right", -1, &glyph));
g_assert_cmpint (parts[2].glyph, ==, glyph);
g_assert_cmpint (parts[2].start_connector_length, ==, 316);
g_assert_cmpint (parts[2].end_connector_length, ==, 454);
g_assert_cmpint (parts[2].full_advance, ==, 2000);
g_assert (!(parts[2].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert_true (!(parts[2].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert (hb_font_get_glyph_from_name (font, "arrowdown", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "arrowdown", -1, &glyph));
offset = 0;
do {
count = partsSize;
@ -779,36 +779,36 @@ test_get_glyph_assembly (void)
offset += count;
} while (count == partsSize);
g_assert_cmpint (offset, ==, 5);
g_assert (hb_font_get_glyph_from_name (font, "bottom", -1, &glyph));
g_assert_true (hb_font_get_glyph_from_name (font, "bottom", -1, &glyph));
g_assert_cmpint (parts[0].glyph, ==, glyph);
g_assert_cmpint (parts[0].start_connector_length, ==, 365);
g_assert_cmpint (parts[0].end_connector_length, ==, 158);
g_assert_cmpint (parts[0].full_advance, ==, 1000);
g_assert (!(parts[0].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert (hb_font_get_glyph_from_name (font, "vertical", -1, &glyph));
g_assert_true (!(parts[0].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert_true (hb_font_get_glyph_from_name (font, "vertical", -1, &glyph));
g_assert_cmpint (parts[1].glyph, ==, glyph);
g_assert_cmpint (parts[1].start_connector_length, ==, 227);
g_assert_cmpint (parts[1].end_connector_length, ==, 365);
g_assert_cmpint (parts[1].full_advance, ==, 1000);
g_assert (parts[1].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER);
g_assert (hb_font_get_glyph_from_name (font, "center", -1, &glyph));
g_assert_true (parts[1].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER);
g_assert_true (hb_font_get_glyph_from_name (font, "center", -1, &glyph));
g_assert_cmpint (parts[2].glyph, ==, glyph);
g_assert_cmpint (parts[2].start_connector_length, ==, 54);
g_assert_cmpint (parts[2].end_connector_length, ==, 158);
g_assert_cmpint (parts[2].full_advance, ==, 1000);
g_assert (!(parts[2].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert (hb_font_get_glyph_from_name (font, "vertical", -1, &glyph));
g_assert_true (!(parts[2].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert_true (hb_font_get_glyph_from_name (font, "vertical", -1, &glyph));
g_assert_cmpint (parts[3].glyph, ==, glyph);
g_assert_cmpint (parts[3].start_connector_length, ==, 400);
g_assert_cmpint (parts[3].end_connector_length, ==, 296);
g_assert_cmpint (parts[3].full_advance, ==, 1000);
g_assert (parts[1].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER);
g_assert (hb_font_get_glyph_from_name (font, "top", -1, &glyph));
g_assert_true (parts[1].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER);
g_assert_true (hb_font_get_glyph_from_name (font, "top", -1, &glyph));
g_assert_cmpint (parts[4].glyph, ==, glyph);
g_assert_cmpint (parts[4].start_connector_length, ==, 123);
g_assert_cmpint (parts[4].end_connector_length, ==, 192);
g_assert_cmpint (parts[4].full_advance, ==, 1000);
g_assert (!(parts[4].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
g_assert_true (!(parts[4].flags & HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER));
hb_font_destroy (font);
hb_face_destroy (face);

View file

@ -33,14 +33,14 @@ static void
test_extents_tt_var (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman-nohvar-41,C1.ttf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 2, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 10);
g_assert_cmpint (extents.y_bearing, ==, 846);
@ -50,7 +50,7 @@ test_extents_tt_var (void)
float coords[1] = { 500.0f };
hb_font_set_var_coords_design (font, coords, 1);
result = hb_font_get_glyph_extents (font, 2, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 874);
@ -64,10 +64,10 @@ static void
test_advance_tt_var_nohvar (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman-nohvar-41,C1.ttf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_position_t x, y;
hb_font_get_glyph_advance_for_direction(font, 2, HB_DIRECTION_LTR, &x, &y);
@ -99,10 +99,10 @@ static void
test_advance_tt_var_hvarvvar (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSerifVariable-Roman-VVAR.abc.ttf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_position_t x, y;
hb_font_get_glyph_advance_for_direction(font, 1, HB_DIRECTION_LTR, &x, &y);
@ -134,14 +134,14 @@ static void
test_advance_tt_var_anchor (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.anchor.ttf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
hb_bool_t result = hb_font_get_glyph_extents (font, 2, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 56);
g_assert_cmpint (extents.y_bearing, ==, 672);
@ -151,7 +151,7 @@ test_advance_tt_var_anchor (void)
float coords[1] = { 500.0f };
hb_font_set_var_coords_design (font, coords, 1);
result = hb_font_get_glyph_extents (font, 2, &extents);
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 50);
g_assert_cmpint (extents.y_bearing, ==, 667);
@ -165,10 +165,10 @@ static void
test_extents_tt_var_comp (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.modcomp.ttf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
hb_glyph_extents_t extents;
float coords[1] = { 800.0f };
@ -176,7 +176,7 @@ test_extents_tt_var_comp (void)
hb_bool_t result;
result = hb_font_get_glyph_extents (font, 2, &extents); /* Ccedilla, cedilla y-scaled by 0.8, with unscaled component offset */
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 19);
g_assert_cmpint (extents.y_bearing, ==, 663);
@ -184,7 +184,7 @@ test_extents_tt_var_comp (void)
g_assert_cmpint (extents.height, ==, -895);
result = hb_font_get_glyph_extents (font, 3, &extents); /* Cacute, acute y-scaled by 0.8, with unscaled component offset (default) */
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 19);
g_assert_cmpint (extents.y_bearing, ==, 909);
@ -192,7 +192,7 @@ test_extents_tt_var_comp (void)
g_assert_cmpint (extents.height, ==, -921);
result = hb_font_get_glyph_extents (font, 4, &extents); /* Ccaron, caron y-scaled by 0.8, with scaled component offset */
g_assert (result);
g_assert_true (result);
g_assert_cmpint (extents.x_bearing, ==, 19);
g_assert_cmpint (extents.y_bearing, ==, 866);
@ -206,10 +206,10 @@ static void
test_advance_tt_var_comp_v (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.modcomp.ttf");
g_assert (face);
g_assert_true (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
g_assert_true (font);
float coords[1] = { 800.0f };
hb_font_set_var_coords_design (font, coords, 1);
@ -239,7 +239,7 @@ test_advance_tt_var_gvar_infer (void)
hb_font_set_var_coords_normalized (font, coords, 6);
hb_glyph_extents_t extents = {0};
g_assert (hb_font_get_glyph_extents (font, 4, &extents));
g_assert_true (hb_font_get_glyph_extents (font, 4, &extents));
hb_font_destroy (font);
}

View file

@ -36,7 +36,7 @@ test_ot_metrics_get_no_var (void)
hb_face_t *face = hb_test_open_font_file ("fonts/cpal-v0.ttf");
hb_font_t *font = hb_font_create (face);
hb_position_t value;
g_assert (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, &value));
g_assert_true (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, &value));
g_assert_cmpint (value, ==, 1000);
g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER), ==, 0);
g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER), ==, 0);
@ -52,14 +52,14 @@ test_ot_metrics_get_var (void)
hb_face_t *face = hb_test_open_font_file ("fonts/TestCFF2VF.otf");
hb_font_t *font = hb_font_create (face);
hb_position_t value;
g_assert (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_X_HEIGHT, &value));
g_assert_true (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_X_HEIGHT, &value));
g_assert_cmpint (value, ==, 486);
g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER), ==, 0);
g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER), ==, 0);
g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_TAG_X_HEIGHT), ==, 0);
float coords[] = {100.f};
hb_font_set_var_coords_design (font, coords, 1);
g_assert (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_X_HEIGHT, &value));
g_assert_true (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_X_HEIGHT, &value));
g_assert_cmpint (value, ==, 478);
g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER), ==, 0);
g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER), ==, 0);

View file

@ -223,7 +223,7 @@ test_language_two_way (const char *tag_s, const char *lang_s)
g_assert_cmphex (tag, ==, tag2);
else
g_assert_cmphex (tag, ==, HB_TAG_CHAR4 ("dflt"));
g_assert (lang == hb_ot_tag_to_language (tag));
g_assert_true (lang == hb_ot_tag_to_language (tag));
}
static void
@ -254,7 +254,7 @@ test_tag_to_language (const char *tag_s, const char *lang_s)
g_test_message ("Testing tag %s -> language %s", tag_s, lang_s);
g_assert (lang == hb_ot_tag_to_language (tag));
g_assert_true (lang == hb_ot_tag_to_language (tag));
}
static void
@ -511,8 +511,8 @@ test_tags (hb_script_t script,
hb_tag_t *script_tags = malloc (script_count * sizeof (hb_tag_t));
hb_tag_t *language_tags = malloc (language_count * sizeof (hb_tag_t));
hb_language_t lang;
g_assert (script_tags);
g_assert (language_tags);
g_assert_true (script_tags);
g_assert_true (language_tags);
lang = hb_language_from_string (lang_s, -1);
va_start (expected_tags, expected_language_count);

View file

@ -36,14 +36,14 @@ test_empty (hb_set_t *s)
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_true (!hb_set_has (s, 13));
next = 53043;
g_assert (!hb_set_next (s, &next));
g_assert_true (!hb_set_next (s, &next));
g_assert_cmpint (next, ==, HB_SET_VALUE_INVALID);
next = 07734;
g_assert (!hb_set_previous (s, &next));
g_assert_true (!hb_set_previous (s, &next));
g_assert_cmpint (next, ==, HB_SET_VALUE_INVALID);
g_assert (hb_set_is_empty (s));
g_assert_true (hb_set_is_empty (s));
}
static void
@ -54,10 +54,10 @@ test_not_empty (hb_set_t *s)
g_assert_cmpint (hb_set_get_min (s), !=, HB_SET_VALUE_INVALID);
g_assert_cmpint (hb_set_get_max (s), !=, HB_SET_VALUE_INVALID);
next = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_cmpint (next, !=, HB_SET_VALUE_INVALID);
next = HB_SET_VALUE_INVALID;
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, !=, HB_SET_VALUE_INVALID);
}
@ -79,47 +79,47 @@ test_set_basic (void)
hb_set_add_range (s, 10, 29);
test_not_empty (s);
g_assert (hb_set_has (s, 13));
g_assert_true (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);
test_not_empty (s);
g_assert (hb_set_has (s, 13));
g_assert_true (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));
g_assert_true (!hb_set_has (s, 13));
hb_set_add_range (s, 200, 800);
test_not_empty (s);
g_assert (!hb_set_has (s, 100));
g_assert (!hb_set_has (s, 199));
g_assert (hb_set_has (s, 200));
g_assert (hb_set_has (s, 201));
g_assert (hb_set_has (s, 243));
g_assert (hb_set_has (s, 254));
g_assert (hb_set_has (s, 255));
g_assert (hb_set_has (s, 256));
g_assert (hb_set_has (s, 257));
g_assert (hb_set_has (s, 511));
g_assert (hb_set_has (s, 512));
g_assert (hb_set_has (s, 600));
g_assert (hb_set_has (s, 767));
g_assert (hb_set_has (s, 768));
g_assert (hb_set_has (s, 769));
g_assert (hb_set_has (s, 782));
g_assert (hb_set_has (s, 798));
g_assert (hb_set_has (s, 799));
g_assert (hb_set_has (s, 800));
g_assert (!hb_set_has (s, 801));
g_assert (!hb_set_has (s, 802));
g_assert_true (!hb_set_has (s, 100));
g_assert_true (!hb_set_has (s, 199));
g_assert_true (hb_set_has (s, 200));
g_assert_true (hb_set_has (s, 201));
g_assert_true (hb_set_has (s, 243));
g_assert_true (hb_set_has (s, 254));
g_assert_true (hb_set_has (s, 255));
g_assert_true (hb_set_has (s, 256));
g_assert_true (hb_set_has (s, 257));
g_assert_true (hb_set_has (s, 511));
g_assert_true (hb_set_has (s, 512));
g_assert_true (hb_set_has (s, 600));
g_assert_true (hb_set_has (s, 767));
g_assert_true (hb_set_has (s, 768));
g_assert_true (hb_set_has (s, 769));
g_assert_true (hb_set_has (s, 782));
g_assert_true (hb_set_has (s, 798));
g_assert_true (hb_set_has (s, 799));
g_assert_true (hb_set_has (s, 800));
g_assert_true (!hb_set_has (s, 801));
g_assert_true (!hb_set_has (s, 802));
hb_set_del (s, 800);
g_assert (!hb_set_has (s, 800));
g_assert_true (!hb_set_has (s, 800));
g_assert_cmpint (hb_set_get_max (s), ==, 799);
@ -152,7 +152,7 @@ static void test_set_intersect_empty (void)
hb_set_add (b, 24064);
hb_set_intersect (a, b);
g_assert (hb_set_is_empty (a));
g_assert_true (hb_set_is_empty (a));
hb_set_destroy (a);
hb_set_destroy (b);
@ -165,7 +165,7 @@ static void test_set_intersect_empty (void)
hb_set_add (b, 0);
hb_set_intersect (a, b);
g_assert (hb_set_is_empty (a));
g_assert_true (hb_set_is_empty (a));
hb_set_destroy (a);
hb_set_destroy (b);
@ -183,7 +183,7 @@ static void test_set_intersect_page_reduction (void)
hb_set_add (b, 24405);
hb_set_intersect(a, b);
g_assert (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (a, b));
hb_set_destroy (a);
hb_set_destroy (b);
@ -208,7 +208,7 @@ static void test_set_union (void)
hb_set_add (u, 24405);
hb_set_union(b, a);
g_assert (hb_set_is_equal (u, b));
g_assert_true (hb_set_is_equal (u, b));
hb_set_destroy (a);
hb_set_destroy (b);
@ -223,24 +223,24 @@ test_set_subsets (void)
hb_set_add (l, 0x0FFFF);
hb_set_add (s, 0x1FFFF);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_clear (s);
hb_set_add (s, 0x0FFF0);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_clear (s);
hb_set_add (s, 0x0AFFF);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_clear (s);
g_assert (hb_set_is_subset (s, l));
g_assert_true (hb_set_is_subset (s, l));
hb_set_clear (l);
g_assert (hb_set_is_subset (s, l));
g_assert_true (hb_set_is_subset (s, l));
hb_set_add (s, 0x1FFFF);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_clear (s);
hb_set_add (s, 0xFF);
@ -251,17 +251,17 @@ test_set_subsets (void)
hb_set_add (l, 0x1FFFF);
hb_set_add (l, 0x2FFFF);
g_assert (hb_set_is_subset (s, l));
g_assert_true (hb_set_is_subset (s, l));
hb_set_del (l, 0xFF);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_add (l, 0xFF);
hb_set_del (l, 0x2FFFF);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_add (l, 0x2FFFF);
hb_set_del (l, 0x1FFFF);
g_assert (!hb_set_is_subset (s, l));
g_assert_true (!hb_set_is_subset (s, l));
hb_set_destroy (s);
hb_set_destroy (l);
@ -280,13 +280,13 @@ test_set_algebra (void)
hb_set_add (o2, 0x660E);
test_empty (s);
g_assert (!hb_set_is_equal (s, o));
g_assert (hb_set_is_subset (s, o));
g_assert (!hb_set_is_subset (o, s));
g_assert_true (!hb_set_is_equal (s, o));
g_assert_true (hb_set_is_subset (s, o));
g_assert_true (!hb_set_is_subset (o, s));
hb_set_set (s, o);
g_assert (hb_set_is_equal (s, o));
g_assert (hb_set_is_subset (s, o));
g_assert (hb_set_is_subset (o, s));
g_assert_true (hb_set_is_equal (s, o));
g_assert_true (hb_set_is_subset (s, o));
g_assert_true (hb_set_is_subset (o, s));
test_not_empty (s);
g_assert_cmpint (hb_set_get_population (s), ==, 2);
@ -296,50 +296,50 @@ test_set_algebra (void)
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));
g_assert_true (hb_set_has (s, 10));
g_assert_true (hb_set_has (s, 13));
hb_set_clear (s);
test_empty (s);
g_assert_cmpint (hb_set_get_population (s), ==, 0);
hb_set_union (s, o2);
g_assert_cmpint (hb_set_get_population (s), ==, 1);
g_assert (hb_set_has (s, 0x660E));
g_assert_true (hb_set_has (s, 0x660E));
hb_set_clear (s);
test_empty (s);
hb_set_add_range (s, 10, 17);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!hb_set_is_equal (s, o));
hb_set_intersect (s, o);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!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));
g_assert_true (!hb_set_has (s, 10));
g_assert_true (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));
g_assert_true (!hb_set_is_equal (s, o));
hb_set_subtract (s, o);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!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));
g_assert_true (hb_set_has (s, 12));
g_assert_true (!hb_set_has (s, 13));
g_assert_true (!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));
g_assert_true (!hb_set_is_equal (s, o));
hb_set_symmetric_difference (s, o);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!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));
g_assert_true (hb_set_has (s, 12));
g_assert_true (!hb_set_has (s, 13));
g_assert_true (hb_set_has (s, 19));
/* https://github.com/harfbuzz/harfbuzz/issues/579 */
hb_set_clear (s);
@ -351,25 +351,25 @@ test_set_algebra (void)
test_empty (o);
hb_set_add (o, 889);
hb_set_add (o, 1024);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!hb_set_is_equal (s, o));
hb_set_intersect (o, s);
test_not_empty (o);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!hb_set_is_equal (s, o));
g_assert_cmpint (hb_set_get_population (o), ==, 2);
g_assert (hb_set_has (o, 889));
g_assert (hb_set_has (o, 1024));
g_assert_true (hb_set_has (o, 889));
g_assert_true (hb_set_has (o, 1024));
hb_set_clear (o);
test_empty (o);
hb_set_add_range (o, 887, 889);
hb_set_add (o, 1121);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!hb_set_is_equal (s, o));
hb_set_intersect (o, s);
test_not_empty (o);
g_assert (!hb_set_is_equal (s, o));
g_assert_true (!hb_set_is_equal (s, o));
g_assert_cmpint (hb_set_get_population (o), ==, 3);
g_assert (hb_set_has (o, 887));
g_assert (hb_set_has (o, 888));
g_assert (hb_set_has (o, 889));
g_assert_true (hb_set_has (o, 887));
g_assert_true (hb_set_has (o, 888));
g_assert_true (hb_set_has (o, 889));
hb_set_clear (s);
test_empty (s);
@ -387,13 +387,13 @@ test_set_algebra (void)
g_assert_cmpint (hb_set_get_population (o), ==, 1);
hb_set_intersect (o, s);
g_assert_cmpint (hb_set_get_population (o), ==, 1);
g_assert (hb_set_has (o, 889));
g_assert_true (hb_set_has (o, 889));
hb_set_add (o, 511);
g_assert_cmpint (hb_set_get_population (o), ==, 2);
hb_set_intersect (o, s);
g_assert_cmpint (hb_set_get_population (o), ==, 1);
g_assert (hb_set_has (o, 889));
g_assert_true (hb_set_has (o, 889));
hb_set_destroy (s);
hb_set_destroy (o);
@ -416,84 +416,84 @@ test_set_iter (void)
test_not_empty (s);
next = HB_SET_VALUE_INVALID;
g_assert (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_cmpint (next, ==, 6);
g_assert (hb_set_next (s, &next));
g_assert_true (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_true (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_true (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_true (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_cmpint (next, ==, 15);
g_assert (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_cmpint (next, ==, 1100);
g_assert (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_cmpint (next, ==, 1200);
g_assert (hb_set_next (s, &next));
g_assert_true (hb_set_next (s, &next));
g_assert_cmpint (next, ==, 20005);
g_assert (!hb_set_next (s, &next));
g_assert_true (!hb_set_next (s, &next));
g_assert_cmpint (next, ==, HB_SET_VALUE_INVALID);
next = HB_SET_VALUE_INVALID;
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 20005);
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 1200);
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 1100);
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 15);
g_assert (hb_set_previous (s, &next));
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 13);
g_assert (hb_set_previous (s, &next));
g_assert (hb_set_previous (s, &next));
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 10);
g_assert (hb_set_previous (s, &next));
g_assert_true (hb_set_previous (s, &next));
g_assert_cmpint (next, ==, 6);
g_assert (!hb_set_previous (s, &next));
g_assert_true (!hb_set_previous (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_true (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_true (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_true (hb_set_next_range (s, &first, &last));
g_assert_cmpint (first, ==, 1100);
g_assert_cmpint (last, ==, 1100);
g_assert (hb_set_next_range (s, &first, &last));
g_assert_true (hb_set_next_range (s, &first, &last));
g_assert_cmpint (first, ==, 1200);
g_assert_cmpint (last, ==, 1200);
g_assert (hb_set_next_range (s, &first, &last));
g_assert_true (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_true (!hb_set_next_range (s, &first, &last));
g_assert_cmpint (first, ==, HB_SET_VALUE_INVALID);
g_assert_cmpint (last, ==, HB_SET_VALUE_INVALID);
first = last = HB_SET_VALUE_INVALID;
g_assert (hb_set_previous_range (s, &first, &last));
g_assert_true (hb_set_previous_range (s, &first, &last));
g_assert_cmpint (first, ==, 20005);
g_assert_cmpint (last, ==, 20005);
g_assert (hb_set_previous_range (s, &first, &last));
g_assert_true (hb_set_previous_range (s, &first, &last));
g_assert_cmpint (first, ==, 1200);
g_assert_cmpint (last, ==, 1200);
g_assert (hb_set_previous_range (s, &first, &last));
g_assert_true (hb_set_previous_range (s, &first, &last));
g_assert_cmpint (first, ==, 1100);
g_assert_cmpint (last, ==, 1100);
g_assert (hb_set_previous_range (s, &first, &last));
g_assert_true (hb_set_previous_range (s, &first, &last));
g_assert_cmpint (first, ==, 10);
g_assert_cmpint (last, ==, 15);
g_assert (hb_set_previous_range (s, &first, &last));
g_assert_true (hb_set_previous_range (s, &first, &last));
g_assert_cmpint (first, ==, 6);
g_assert_cmpint (last, ==, 6);
g_assert (!hb_set_previous_range (s, &first, &last));
g_assert_true (!hb_set_previous_range (s, &first, &last));
g_assert_cmpint (first, ==, HB_SET_VALUE_INVALID);
g_assert_cmpint (last, ==, HB_SET_VALUE_INVALID);
@ -505,10 +505,10 @@ 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_true (hb_set_get_empty ());
g_assert_true (hb_set_get_empty () == b);
g_assert (!hb_set_allocation_successful (b));
g_assert_true (!hb_set_allocation_successful (b));
test_empty (b);
@ -516,13 +516,13 @@ test_set_empty (void)
test_empty (b);
g_assert (!hb_set_allocation_successful (b));
g_assert_true (!hb_set_allocation_successful (b));
hb_set_clear (b);
test_empty (b);
g_assert (!hb_set_allocation_successful (b));
g_assert_true (!hb_set_allocation_successful (b));
hb_set_destroy (b);
}
@ -565,10 +565,10 @@ test_set_delrange (void)
{
unsigned b = ranges[i].b;
unsigned e = ranges[i].e;
g_assert (hb_set_has (s, (b-2)&~1));
g_assert_true (hb_set_has (s, (b-2)&~1));
while (b <= e)
g_assert (!hb_set_has (s, b++));
g_assert (hb_set_has (s, (e+2)&~1));
g_assert_true (!hb_set_has (s, b++));
g_assert_true (hb_set_has (s, (e+2)&~1));
}
hb_set_destroy (s);
@ -586,29 +586,29 @@ test_set_inverted_basics (void)
hb_set_invert (s);
g_assert_cmpint (hb_set_get_population (s), ==, max_set_elements);
g_assert (hb_set_has (s, 0));
g_assert (hb_set_has (s, 13));
g_assert (hb_set_has (s, max_set_elements - 1));
g_assert (!hb_set_is_empty (s));
g_assert_true (hb_set_has (s, 0));
g_assert_true (hb_set_has (s, 13));
g_assert_true (hb_set_has (s, max_set_elements - 1));
g_assert_true (!hb_set_is_empty (s));
g_assert_cmpint (hb_set_get_min (s), ==, 0);
g_assert_cmpint (hb_set_get_max (s), ==, max_set_elements - 1);
hb_set_del (s, 13);
g_assert (!hb_set_has (s, 13));
g_assert_true (!hb_set_has (s, 13));
g_assert_cmpint (hb_set_get_population (s), ==, max_set_elements - 1);
g_assert_cmpint (hb_set_get_min (s), ==, 0);
g_assert_cmpint (hb_set_get_max (s), ==, max_set_elements - 1);
hb_set_add (s, 13);
g_assert (hb_set_has (s, 13));
g_assert_true (hb_set_has (s, 13));
g_assert_cmpint (hb_set_get_population (s), ==, max_set_elements);
hb_set_del (s, 0);
hb_set_del (s, max_set_elements - 1);
g_assert (!hb_set_has (s, 0));
g_assert (hb_set_has (s, 13));
g_assert (!hb_set_has (s, max_set_elements - 1));
g_assert (!hb_set_is_empty (s));
g_assert_true (!hb_set_has (s, 0));
g_assert_true (hb_set_has (s, 13));
g_assert_true (!hb_set_has (s, max_set_elements - 1));
g_assert_true (!hb_set_is_empty (s));
g_assert_cmpint (hb_set_get_population (s), ==, max_set_elements - 2);
g_assert_cmpint (hb_set_get_min (s), ==, 1);
g_assert_cmpint (hb_set_get_max (s), ==, max_set_elements - 2);
@ -628,39 +628,39 @@ test_set_inverted_ranges (void)
hb_set_del_range (s, 41, 4000);
hb_set_add_range (s, 78, 601);
g_assert (hb_set_has (s, 40));
g_assert (!hb_set_has (s, 41));
g_assert (!hb_set_has (s, 64));
g_assert (!hb_set_has (s, 77));
g_assert (hb_set_has (s, 78));
g_assert (hb_set_has (s, 300));
g_assert (hb_set_has (s, 601));
g_assert (!hb_set_has (s, 602));
g_assert (!hb_set_has (s, 3000));
g_assert (!hb_set_has (s, 4000));
g_assert (hb_set_has (s, 4001));
g_assert_true (hb_set_has (s, 40));
g_assert_true (!hb_set_has (s, 41));
g_assert_true (!hb_set_has (s, 64));
g_assert_true (!hb_set_has (s, 77));
g_assert_true (hb_set_has (s, 78));
g_assert_true (hb_set_has (s, 300));
g_assert_true (hb_set_has (s, 601));
g_assert_true (!hb_set_has (s, 602));
g_assert_true (!hb_set_has (s, 3000));
g_assert_true (!hb_set_has (s, 4000));
g_assert_true (hb_set_has (s, 4001));
g_assert (!hb_set_is_empty (s));
g_assert_true (!hb_set_is_empty (s));
g_assert_cmpint (hb_set_get_population (s), ==, max_set_elements - 3436);
g_assert_cmpint (hb_set_get_min (s), ==, 0);
g_assert_cmpint (hb_set_get_max (s), ==, max_set_elements - 1);
hb_set_del_range (s, 0, 37);
g_assert (!hb_set_has (s, 0));
g_assert (!hb_set_has (s, 37));
g_assert (hb_set_has (s, 38));
g_assert (!hb_set_is_empty (s));
g_assert_true (!hb_set_has (s, 0));
g_assert_true (!hb_set_has (s, 37));
g_assert_true (hb_set_has (s, 38));
g_assert_true (!hb_set_is_empty (s));
g_assert_cmpint (hb_set_get_population (s), ==,
max_set_elements - 3436 - 38);
g_assert_cmpint (hb_set_get_min (s), ==, 38);
g_assert_cmpint (hb_set_get_max (s), ==, max_set_elements - 1);
hb_set_del_range (s, max_set_elements - 13, max_set_elements - 1);
g_assert (!hb_set_has (s, max_set_elements - 1));
g_assert (!hb_set_has (s, max_set_elements - 13));
g_assert (hb_set_has (s, max_set_elements - 14));
g_assert_true (!hb_set_has (s, max_set_elements - 1));
g_assert_true (!hb_set_has (s, max_set_elements - 13));
g_assert_true (hb_set_has (s, max_set_elements - 14));
g_assert (!hb_set_is_empty (s));
g_assert_true (!hb_set_is_empty (s));
g_assert_cmpint (hb_set_get_population (s), ==,
max_set_elements - 3436 - 38 - 13);
g_assert_cmpint (hb_set_get_min (s), ==, 38);
@ -683,90 +683,90 @@ test_set_inverted_iteration_next (void)
hb_codepoint_t cp = HB_SET_VALUE_INVALID;
hb_codepoint_t start = 0;
hb_codepoint_t end = 0;
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 0);
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 1);
g_assert (hb_set_next_range (s, &start, &end));
g_assert_true (hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, 1);
g_assert_cmpint (end, ==, 40);
start = 40;
end = 40;
g_assert (hb_set_next_range (s, &start, &end));
g_assert_true (hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, 78);
g_assert_cmpint (end, ==, 601);
start = 40;
end = 57;
g_assert (hb_set_next_range (s, &start, &end));
g_assert_true (hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, 78);
g_assert_cmpint (end, ==, 601);
cp = 39;
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 40);
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 78);
cp = 56;
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 78);
cp = 78;
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 79);
cp = 601;
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 4001);
cp = HB_SET_VALUE_INVALID;
hb_set_del (s, 0);
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, 1);
start = 0;
end = 0;
g_assert (hb_set_next_range (s, &start, &end));
g_assert_true (hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, 1);
g_assert_cmpint (end, ==, 40);
cp = max_set_elements - 1;
g_assert (!hb_set_next (s, &cp));
g_assert_true (!hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, HB_SET_VALUE_INVALID);
start = 4000;
end = 4000;
g_assert (hb_set_next_range (s, &start, &end));
g_assert_true (hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, 4001);
g_assert_cmpint (end, ==, max_set_elements - 1);
start = max_set_elements - 1;
end = max_set_elements - 1;
g_assert (!hb_set_next_range (s, &start, &end));
g_assert_true (!hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, HB_SET_VALUE_INVALID);
g_assert_cmpint (end, ==, HB_SET_VALUE_INVALID);
cp = max_set_elements - 3;
hb_set_del (s, max_set_elements - 1);
g_assert (hb_set_next (s, &cp));
g_assert_true (hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, max_set_elements - 2);
g_assert (!hb_set_next (s, &cp));
g_assert_true (!hb_set_next (s, &cp));
g_assert_cmpint (cp, ==, HB_SET_VALUE_INVALID);
start = max_set_elements - 2;
end = max_set_elements - 2;
g_assert (!hb_set_next_range (s, &start, &end));
g_assert_true (!hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, HB_SET_VALUE_INVALID);
g_assert_cmpint (end, ==, HB_SET_VALUE_INVALID);
start = max_set_elements - 3;
end = max_set_elements - 3;
g_assert (hb_set_next_range (s, &start, &end));
g_assert_true (hb_set_next_range (s, &start, &end));
g_assert_cmpint (start, ==, max_set_elements - 2);
g_assert_cmpint (end, ==, max_set_elements - 2);
@ -787,94 +787,94 @@ test_set_inverted_iteration_prev (void)
hb_codepoint_t cp = HB_SET_VALUE_INVALID;
hb_codepoint_t start = max_set_elements - 1;
hb_codepoint_t end = max_set_elements - 1;
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, max_set_elements - 1);
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, max_set_elements - 2);
g_assert (hb_set_previous_range (s, &start, &end));
g_assert_true (hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, 4001);
g_assert_cmpint (end, ==, max_set_elements - 2);
start = 4001;
end = 4001;
g_assert (hb_set_previous_range (s, &start, &end));
g_assert_true (hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, 78);
g_assert_cmpint (end, ==, 601);
start = 2500;
end = 3000;
g_assert (hb_set_previous_range (s, &start, &end));
g_assert_true (hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, 78);
g_assert_cmpint (end, ==, 601);
cp = 4002;
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 4001);
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 601);
cp = 3500;
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 601);
cp = 601;
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 600);
cp = 78;
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 40);
cp = HB_SET_VALUE_INVALID;
hb_set_del (s, max_set_elements - 1);
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, max_set_elements - 2);
start = max_set_elements - 1;
end = max_set_elements - 1;
g_assert (hb_set_previous_range (s, &start, &end));
g_assert_true (hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, 4001);
g_assert_cmpint (end, ==, max_set_elements - 2);
cp = 0;
g_assert (!hb_set_previous (s, &cp));
g_assert_true (!hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, HB_SET_VALUE_INVALID);
cp = 40;
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 39);
start = 40;
end = 40;
g_assert (hb_set_previous_range (s, &start, &end));
g_assert_true (hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, 0);
g_assert_cmpint (end, ==, 39);
start = 0;
end = 0;
g_assert (!hb_set_previous_range (s, &start, &end));
g_assert_true (!hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, HB_SET_VALUE_INVALID);
g_assert_cmpint (end, ==, HB_SET_VALUE_INVALID);
cp = 2;
hb_set_del (s, 0);
g_assert (hb_set_previous (s, &cp));
g_assert_true (hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, 1);
g_assert (!hb_set_previous (s, &cp));
g_assert_true (!hb_set_previous (s, &cp));
g_assert_cmpint (cp, ==, HB_SET_VALUE_INVALID);
start = 1;
end = 1;
g_assert (!hb_set_previous_range (s, &start, &end));
g_assert_true (!hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, HB_SET_VALUE_INVALID);
g_assert_cmpint (end, ==, HB_SET_VALUE_INVALID);
start = 2;
end = 2;
g_assert (hb_set_previous_range (s, &start, &end));
g_assert_true (hb_set_previous_range (s, &start, &end));
g_assert_cmpint (start, ==, 1);
g_assert_cmpint (end, ==, 1);
@ -890,50 +890,50 @@ test_set_inverted_equality (void)
hb_set_invert (a);
hb_set_invert (b);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_add (a, 10);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_del (a, 42);
g_assert (!hb_set_is_equal (a, b));
g_assert (!hb_set_is_equal (b, a));
g_assert_true (!hb_set_is_equal (a, b));
g_assert_true (!hb_set_is_equal (b, a));
hb_set_del (b, 42);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_del_range (a, 43, 50);
hb_set_del_range (a, 51, 76);
hb_set_del_range (b, 43, 76);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_del (a, 0);
g_assert (!hb_set_is_equal (a, b));
g_assert (!hb_set_is_equal (b, a));
g_assert_true (!hb_set_is_equal (a, b));
g_assert_true (!hb_set_is_equal (b, a));
hb_set_del (b, 0);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_del (a, max_set_elements - 1);
g_assert (!hb_set_is_equal (a, b));
g_assert (!hb_set_is_equal (b, a));
g_assert_true (!hb_set_is_equal (a, b));
g_assert_true (!hb_set_is_equal (b, a));
hb_set_del (b, max_set_elements - 1);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_invert (a);
g_assert (!hb_set_is_equal (a, b));
g_assert (!hb_set_is_equal (b, a));
g_assert_true (!hb_set_is_equal (a, b));
g_assert_true (!hb_set_is_equal (b, a));
hb_set_invert (b);
g_assert (hb_set_is_equal (a, b));
g_assert (hb_set_is_equal (b, a));
g_assert_true (hb_set_is_equal (a, b));
g_assert_true (hb_set_is_equal (b, a));
hb_set_destroy (a);
hb_set_destroy (b);
@ -1018,18 +1018,19 @@ check_set_operations(hb_bool_t a_has_x,
break;
}
printf ("%s%s%s%s %-9s %s%s%s%s == %s [%s]\n",
a_inverted ? "i" : " ",
a_has_page ? "p" : " ",
a_is_null ? "n" : " ",
a_has_x ? "{13}" : "{} ",
op_name,
b_inverted ? "i" : " ",
b_has_page ? "p" : " ",
b_is_null ? "n" : " ",
b_has_x ? "{13}" : "{} ",
should_have_x ? "{13}" : "{} ",
has_expected ? "succeeded" : "failed");
if (FALSE)
printf ("%s%s%s%s %-9s %s%s%s%s == %s [%s]\n",
a_inverted ? "i" : " ",
a_has_page ? "p" : " ",
a_is_null ? "n" : " ",
a_has_x ? "{13}" : "{} ",
op_name,
b_inverted ? "i" : " ",
b_has_page ? "p" : " ",
b_is_null ? "n" : " ",
b_has_x ? "{13}" : "{} ",
should_have_x ? "{13}" : "{} ",
has_expected ? "succeeded" : "failed");
hb_set_destroy (a);
hb_set_destroy (b);
@ -1064,7 +1065,7 @@ test_set_inverted_operations (void)
}
}
g_assert (all_succeeded);
g_assert_true (all_succeeded);
}
static void
@ -1074,13 +1075,13 @@ test_hb_set_add_sorted_array (void)
hb_codepoint_t array[7] = {1, 2, 3, 1000, 2000, 2001, 2002};
hb_set_add_sorted_array (set, array, 7);
g_assert_cmpint (hb_set_get_population (set), ==, 7);
g_assert (hb_set_has (set, 1));
g_assert (hb_set_has (set, 2));
g_assert (hb_set_has (set, 3));
g_assert (hb_set_has (set, 1000));
g_assert (hb_set_has (set, 2000));
g_assert (hb_set_has (set, 2001));
g_assert (hb_set_has (set, 2002));
g_assert_true (hb_set_has (set, 1));
g_assert_true (hb_set_has (set, 2));
g_assert_true (hb_set_has (set, 3));
g_assert_true (hb_set_has (set, 1000));
g_assert_true (hb_set_has (set, 2000));
g_assert_true (hb_set_has (set, 2001));
g_assert_true (hb_set_has (set, 2002));
hb_set_destroy (set);
}
@ -1092,7 +1093,7 @@ test_set_next_many (void)
hb_set_add (set, i);
for (unsigned i=6000; i<6100; i++)
hb_set_add (set, i);
g_assert (hb_set_get_population (set) == 700);
g_assert_true (hb_set_get_population (set) == 700);
hb_codepoint_t array[700];
unsigned int n = hb_set_next_many (set, HB_SET_VALUE_INVALID, array, 700);
@ -1101,7 +1102,7 @@ test_set_next_many (void)
for (unsigned i=0; i<600; i++)
g_assert_cmpint (array[i], ==, i);
for (unsigned i=0; i<100; i++)
g_assert (array[600 + i] == 6000u + i);
g_assert_true (array[600 + i] == 6000u + i);
// Try skipping initial values.
for (unsigned i = 0; i < 700; i++)
@ -1124,7 +1125,7 @@ test_set_next_many_restricted (void)
hb_set_add (set, i);
for (int i=6000; i<6100; i++)
hb_set_add (set, i);
g_assert (hb_set_get_population (set) == 700);
g_assert_true (hb_set_get_population (set) == 700);
hb_codepoint_t array[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
hb_set_next_many (set, HB_SET_VALUE_INVALID, array, 9);

View file

@ -190,7 +190,7 @@ test_shape_list (void)
;
g_assert_cmpint (i, >, 1);
g_assert (!strcmp (shapers[i - 1], "fallback"));
g_assert_true (!strcmp (shapers[i - 1], "fallback"));
}
int

View file

@ -43,14 +43,14 @@ test_subset_drop_tables (void)
hb_set_destroy (codepoints);
hb_face_t* subset = hb_subset_or_fail (face, input);
g_assert (subset);
g_assert_true (subset);
hb_blob_t *hdmx = hb_face_reference_table (subset, HB_TAG ('h', 'd', 'm', 'x'));
hb_blob_t *hmtx = hb_face_reference_table (subset, HB_TAG ('h', 'm', 't', 'x'));
hb_blob_t *cmap = hb_face_reference_table (subset, HB_TAG ('c', 'm', 'a', 'p'));
g_assert (!hb_blob_get_length (hdmx));
g_assert (!hb_blob_get_length (hmtx));
g_assert ( hb_blob_get_length (cmap));
g_assert_true (!hb_blob_get_length (hdmx));
g_assert_true (!hb_blob_get_length (hmtx));
g_assert_true ( hb_blob_get_length (cmap));
hb_blob_destroy (hdmx);
hb_blob_destroy (hmtx);
hb_blob_destroy (cmap);

View file

@ -302,7 +302,7 @@ test_subset_glyf_strip_hints_invalid (void)
hb_set_destroy (codepoints);
face_subset = hb_subset_or_fail (face, input);
g_assert (!face_subset);
g_assert_true (!face_subset);
hb_subset_input_destroy (input);
hb_face_destroy (face);

View file

@ -83,7 +83,7 @@ test_subset_hdmx_invalid (void)
hb_set_add (codepoints, 'c');
subset = hb_subset_or_fail (face, input);
g_assert (!subset);
g_assert_true (!subset);
hb_subset_input_destroy (input);
hb_face_destroy (subset);

View file

@ -163,7 +163,7 @@ test_subset_invalid_hmtx (void)
hb_set_add (codepoints, 'c');
subset = hb_subset_or_fail (face, input);
g_assert (!subset);
g_assert_true (!subset);
hb_subset_input_destroy (input);
hb_face_destroy (subset);

View file

@ -80,7 +80,7 @@ test_subset_name_overrides (void)
char str6[] = "Roboto-Bold";
char str12[] = "Non ascii test Ü";
char str16[] = "Roboto-test-inserting";
hb_set_t *name_ids = hb_set_create();
hb_face_t *face_subset;
hb_set_add_range (name_ids, 0, 13);

View file

@ -187,7 +187,6 @@ test_hb_repack_with_cy_struct (void)
hb_face_t *face_expected = hb_test_open_font_file ("fonts/repacker_expected.otf");
hb_blob_t *expected_blob = hb_face_reference_table (face_expected, HB_TAG ('G','S','U','B'));
fprintf(stderr, "expected %d bytes, actual %d bytes\n", hb_blob_get_length(expected_blob), hb_blob_get_length (result));
if (hb_blob_get_length (expected_blob) != 0 ||
hb_blob_get_length (result) != 0)

View file

@ -43,7 +43,7 @@ test_subset_32_tables (void)
hb_set_add (codepoints, 'c');
subset = hb_subset_or_fail (face, input);
g_assert (!subset);
g_assert_true (!subset);
hb_subset_input_destroy (input);
hb_face_destroy (subset);
@ -64,7 +64,7 @@ test_subset_no_inf_loop (void)
hb_set_add (codepoints, 'c');
subset = hb_subset_or_fail (face, input);
g_assert (!subset);
g_assert_true (!subset);
hb_subset_input_destroy (input);
hb_face_destroy (subset);
@ -85,7 +85,7 @@ test_subset_crash (void)
hb_set_add (codepoints, 'c');
subset = hb_subset_or_fail (face, input);
g_assert (!subset);
g_assert_true (!subset);
hb_subset_input_destroy (input);
hb_face_destroy (subset);
@ -97,14 +97,14 @@ test_subset_set_flags (void)
{
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
g_assert (hb_subset_input_get_flags (input) == HB_SUBSET_FLAGS_DEFAULT);
g_assert_true (hb_subset_input_get_flags (input) == HB_SUBSET_FLAGS_DEFAULT);
hb_subset_input_set_flags (input,
HB_SUBSET_FLAGS_NAME_LEGACY |
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
HB_SUBSET_FLAGS_GLYPH_NAMES);
g_assert (hb_subset_input_get_flags (input) ==
g_assert_true (hb_subset_input_get_flags (input) ==
(hb_subset_flags_t) (
HB_SUBSET_FLAGS_NAME_LEGACY |
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
@ -115,7 +115,7 @@ test_subset_set_flags (void)
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES);
g_assert (hb_subset_input_get_flags (input) ==
g_assert_true (hb_subset_input_get_flags (input) ==
(hb_subset_flags_t) (
HB_SUBSET_FLAGS_NAME_LEGACY |
HB_SUBSET_FLAGS_NOTDEF_OUTLINE |
@ -139,15 +139,15 @@ test_subset_sets (void)
hb_set_add (hb_subset_input_set (input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG), 87);
hb_set_add (set, 83);
g_assert (hb_set_is_equal (hb_subset_input_glyph_set (input), set));
g_assert_true (hb_set_is_equal (hb_subset_input_glyph_set (input), set));
hb_set_clear (set);
hb_set_add (set, 85);
g_assert (hb_set_is_equal (hb_subset_input_unicode_set (input), set));
g_assert_true (hb_set_is_equal (hb_subset_input_unicode_set (input), set));
hb_set_clear (set);
hb_set_add (set, 87);
g_assert (hb_set_is_equal (hb_subset_input_set (input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG), set));
g_assert_true (hb_set_is_equal (hb_subset_input_set (input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG), set));
hb_set_clear (set);
hb_set_destroy (set);
@ -167,18 +167,18 @@ test_subset_plan (void)
hb_set_destroy (codepoints);
hb_subset_plan_t* plan = hb_subset_plan_create_or_fail (face_abc, input);
g_assert (plan);
g_assert_true (plan);
const hb_map_t* mapping = hb_subset_plan_old_to_new_glyph_mapping (plan);
g_assert (hb_map_get (mapping, 1) == 1);
g_assert (hb_map_get (mapping, 3) == 2);
g_assert_true (hb_map_get (mapping, 1) == 1);
g_assert_true (hb_map_get (mapping, 3) == 2);
mapping = hb_subset_plan_new_to_old_glyph_mapping (plan);
g_assert (hb_map_get (mapping, 1) == 1);
g_assert (hb_map_get (mapping, 2) == 3);
g_assert_true (hb_map_get (mapping, 1) == 1);
g_assert_true (hb_map_get (mapping, 2) == 3);
mapping = hb_subset_plan_unicode_to_old_glyph_mapping (plan);
g_assert (hb_map_get (mapping, 0x63) == 3);
g_assert_true (hb_map_get (mapping, 0x63) == 3);
hb_face_t* face_abc_subset = hb_subset_plan_execute_or_fail (plan);
@ -272,19 +272,19 @@ test_subset_cff2_get_charstring_data (void)
hb_blob_t* cs0 = hb_subset_cff2_get_charstring_data (face, 0);
unsigned int length;
const uint8_t* data = (const uint8_t*) hb_blob_get_data (cs0, &length);
g_assert (length == 2);
g_assert (data[0] == 0x20);
g_assert (data[1] == 0x0A);
g_assert_true (length == 2);
g_assert_true (data[0] == 0x20);
g_assert_true (data[1] == 0x0A);
hb_blob_t* cs1 = hb_subset_cff2_get_charstring_data (face, 1);
data = (const uint8_t*) hb_blob_get_data (cs1, &length);
g_assert (length == 2);
g_assert (data[0] == 0x20);
g_assert (data[1] == 0x0A);
g_assert_true (length == 2);
g_assert_true (data[0] == 0x20);
g_assert_true (data[1] == 0x0A);
hb_blob_t* cs2 = hb_subset_cff2_get_charstring_data (face, 2);
data = (const uint8_t*) hb_blob_get_data (cs2, &length);
g_assert (length == 0);
g_assert_true (length == 0);
hb_blob_destroy (cff2);
hb_blob_destroy (maxp);
@ -337,7 +337,7 @@ test_subset_cff2_get_charstring_data_no_cff (void)
hb_face_t* face = hb_face_create (face_blob, 0);
hb_blob_t* cs0 = hb_subset_cff2_get_charstring_data (face, 0);
g_assert (hb_blob_get_length (cs0) == 0);
g_assert_true (hb_blob_get_length (cs0) == 0);
hb_face_destroy (builder);
hb_blob_destroy (face_blob);
@ -357,7 +357,7 @@ test_subset_cff2_get_charstring_data_invalid_cff2 (void)
hb_face_t* face = hb_face_create (face_blob, 0);
hb_blob_t* cs0 = hb_subset_cff2_get_charstring_data (face, 0);
g_assert (hb_blob_get_length (cs0) == 0);
g_assert_true (hb_blob_get_length (cs0) == 0);
hb_blob_destroy (cff2);
hb_face_destroy (builder);
@ -394,9 +394,9 @@ test_subset_cff2_get_charstring_data_lifetime (void)
unsigned int length;
const uint8_t* data = (const uint8_t*) hb_blob_get_data (cs0, &length);
g_assert (length == 2);
g_assert (data[0] == 0x20);
g_assert (data[1] == 0x0A);
g_assert_true (length == 2);
g_assert_true (data[0] == 0x20);
g_assert_true (data[1] == 0x0A);
hb_blob_destroy (cs0);
}

View file

@ -55,8 +55,8 @@ static void free_up (void *p)
{
data_t *data = (data_t *) p;
g_assert (data->value == MAGIC0 || data->value == MAGIC1);
g_assert (!data->freed);
g_assert_true (data->value == MAGIC0 || data->value == MAGIC1);
g_assert_true (!data->freed);
data->freed = TRUE;
}
@ -67,9 +67,9 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
{
data_t *data = (data_t *) user_data;
g_assert (hb_unicode_funcs_get_parent (ufuncs) != NULL);
g_assert_true (hb_unicode_funcs_get_parent (ufuncs) != NULL);
g_assert_cmphex (data->value, ==, MAGIC0);
g_assert (!data->freed);
g_assert_true (!data->freed);
if ('a' <= codepoint && codepoint <= 'z')
return HB_SCRIPT_LATIN;
@ -84,9 +84,9 @@ a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
{
data_t *data = (data_t *) user_data;
g_assert (hb_unicode_funcs_get_parent (ufuncs) != NULL);
g_assert_true (hb_unicode_funcs_get_parent (ufuncs) != NULL);
g_assert_cmphex (data->value, ==, MAGIC1);
g_assert (!data->freed);
g_assert_true (!data->freed);
if (codepoint == 'a') {
return HB_SCRIPT_ARABIC;
@ -609,8 +609,8 @@ test_unicode_properties (gconstpointer user_data, hb_bool_t lenient)
unsigned int i, j;
gboolean failed = TRUE;
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert (hb_unicode_funcs_get_parent (uf));
g_assert_true (hb_unicode_funcs_is_immutable (uf));
g_assert_true (hb_unicode_funcs_get_parent (uf));
for (i = 0; i < G_N_ELEMENTS (properties); i++) {
const property_t *p = &properties[i];
@ -686,7 +686,7 @@ test_unicode_properties_nil (void)
{
hb_unicode_funcs_t *uf = hb_unicode_funcs_create (NULL);
g_assert (!hb_unicode_funcs_is_immutable (uf));
g_assert_true (!hb_unicode_funcs_is_immutable (uf));
_test_unicode_properties_nil (uf);
hb_unicode_funcs_destroy (uf);
@ -697,8 +697,8 @@ test_unicode_properties_empty (void)
{
hb_unicode_funcs_t *uf = hb_unicode_funcs_get_empty ();
g_assert (uf);
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert_true (uf);
g_assert_true (hb_unicode_funcs_is_immutable (uf));
_test_unicode_properties_nil (uf);
}
@ -711,13 +711,13 @@ test_unicode_chainup (void)
/* Chain-up to nil */
uf = hb_unicode_funcs_create (NULL);
g_assert (!hb_unicode_funcs_is_immutable (uf));
g_assert_true (!hb_unicode_funcs_is_immutable (uf));
uf2 = hb_unicode_funcs_create (uf);
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert_true (hb_unicode_funcs_is_immutable (uf));
hb_unicode_funcs_destroy (uf);
g_assert (!hb_unicode_funcs_is_immutable (uf2));
g_assert_true (!hb_unicode_funcs_is_immutable (uf2));
_test_unicode_properties_nil (uf2);
hb_unicode_funcs_destroy (uf2);
@ -725,13 +725,13 @@ test_unicode_chainup (void)
/* Chain-up to default */
uf = hb_unicode_funcs_create (hb_unicode_funcs_get_default ());
g_assert (!hb_unicode_funcs_is_immutable (uf));
g_assert_true (!hb_unicode_funcs_is_immutable (uf));
uf2 = hb_unicode_funcs_create (uf);
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert_true (hb_unicode_funcs_is_immutable (uf));
hb_unicode_funcs_destroy (uf);
g_assert (!hb_unicode_funcs_is_immutable (uf2));
g_assert_true (!hb_unicode_funcs_is_immutable (uf2));
hb_unicode_funcs_make_immutable (uf2);
test_unicode_properties_strict (uf2);
@ -755,7 +755,7 @@ test_unicode_setters (void)
g_test_message ("Testing property %s", p->name);
uf = hb_unicode_funcs_create (NULL);
g_assert (!hb_unicode_funcs_is_immutable (uf));
g_assert_true (!hb_unicode_funcs_is_immutable (uf));
p->func_setter (uf, (get_func_t) simple_get_script, &data[0], free_up);
@ -763,18 +763,18 @@ test_unicode_setters (void)
g_assert_cmphex (p->getter (uf, '0'), ==, HB_SCRIPT_UNKNOWN);
p->func_setter (uf, (get_func_t) NULL, NULL, NULL);
g_assert (data[0].freed && !data[1].freed);
g_assert_true (data[0].freed && !data[1].freed);
g_assert (!hb_unicode_funcs_is_immutable (uf));
g_assert_true (!hb_unicode_funcs_is_immutable (uf));
hb_unicode_funcs_make_immutable (uf);
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert_true (hb_unicode_funcs_is_immutable (uf));
/* Since uf is immutable now, the following setter should do nothing. */
p->func_setter (uf, (get_func_t) a_is_for_arabic_get_script, &data[1], free_up);
g_assert (data[0].freed && data[1].freed);
g_assert_true (data[0].freed && data[1].freed);
hb_unicode_funcs_destroy (uf);
g_assert (data[0].freed && data[1].freed);
g_assert_true (data[0].freed && data[1].freed);
}
}
@ -812,9 +812,9 @@ test_unicode_subclassing_nil (data_fixture_t *f, gconstpointer user_data HB_UNUS
g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_UNKNOWN);
g_assert (!f->data[0].freed && !f->data[1].freed);
g_assert_true (!f->data[0].freed && !f->data[1].freed);
hb_unicode_funcs_destroy (aa);
g_assert (!f->data[0].freed && f->data[1].freed);
g_assert_true (!f->data[0].freed && f->data[1].freed);
}
static void
@ -831,9 +831,9 @@ test_unicode_subclassing_default (data_fixture_t *f, gconstpointer user_data HB_
g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_LATIN);
g_assert (!f->data[0].freed && !f->data[1].freed);
g_assert_true (!f->data[0].freed && !f->data[1].freed);
hb_unicode_funcs_destroy (aa);
g_assert (!f->data[0].freed && f->data[1].freed);
g_assert_true (!f->data[0].freed && f->data[1].freed);
}
static void
@ -851,7 +851,7 @@ test_unicode_subclassing_deep (data_fixture_t *f, gconstpointer user_data HB_UNU
hb_unicode_funcs_destroy (uf);
/* make sure the 'uf' didn't get freed, since 'aa' holds a ref */
g_assert (!f->data[0].freed);
g_assert_true (!f->data[0].freed);
hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
&f->data[1], free_up);
@ -860,9 +860,9 @@ test_unicode_subclassing_deep (data_fixture_t *f, gconstpointer user_data HB_UNU
g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_LATIN);
g_assert_cmphex (hb_unicode_script (aa, '0'), ==, HB_SCRIPT_UNKNOWN);
g_assert (!f->data[0].freed && !f->data[1].freed);
g_assert_true (!f->data[0].freed && !f->data[1].freed);
hb_unicode_funcs_destroy (aa);
g_assert (f->data[0].freed && f->data[1].freed);
g_assert_true (f->data[0].freed && f->data[1].freed);
}
@ -931,67 +931,67 @@ test_unicode_normalization (gconstpointer user_data)
/* Test compose() */
/* Not composable */
g_assert (!hb_unicode_compose (uf, 0x0041, 0x0042, &ab) && ab == 0);
g_assert (!hb_unicode_compose (uf, 0x0041, 0, &ab) && ab == 0);
g_assert (!hb_unicode_compose (uf, 0x0066, 0x0069, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x0041, 0x0042, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x0041, 0, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x0066, 0x0069, &ab) && ab == 0);
/* Singletons should not compose */
g_assert (!hb_unicode_compose (uf, 0x212B, 0, &ab) && ab == 0);
g_assert (!hb_unicode_compose (uf, 0x00C5, 0, &ab) && ab == 0);
g_assert (!hb_unicode_compose (uf, 0x2126, 0, &ab) && ab == 0);
g_assert (!hb_unicode_compose (uf, 0x03A9, 0, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x212B, 0, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x00C5, 0, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x2126, 0, &ab) && ab == 0);
g_assert_true (!hb_unicode_compose (uf, 0x03A9, 0, &ab) && ab == 0);
/* Non-starter pairs should not compose */
g_assert (!hb_unicode_compose (uf, 0x0308, 0x0301, &ab) && ab == 0); /* !0x0344 */
g_assert (!hb_unicode_compose (uf, 0x0F71, 0x0F72, &ab) && ab == 0); /* !0x0F73 */
g_assert_true (!hb_unicode_compose (uf, 0x0308, 0x0301, &ab) && ab == 0); /* !0x0344 */
g_assert_true (!hb_unicode_compose (uf, 0x0F71, 0x0F72, &ab) && ab == 0); /* !0x0F73 */
/* Pairs */
g_assert (hb_unicode_compose (uf, 0x0041, 0x030A, &ab) && ab == 0x00C5);
g_assert (hb_unicode_compose (uf, 0x006F, 0x0302, &ab) && ab == 0x00F4);
g_assert (hb_unicode_compose (uf, 0x1E63, 0x0307, &ab) && ab == 0x1E69);
g_assert (hb_unicode_compose (uf, 0x0073, 0x0323, &ab) && ab == 0x1E63);
g_assert (hb_unicode_compose (uf, 0x0064, 0x0307, &ab) && ab == 0x1E0B);
g_assert (hb_unicode_compose (uf, 0x0064, 0x0323, &ab) && ab == 0x1E0D);
g_assert_true (hb_unicode_compose (uf, 0x0041, 0x030A, &ab) && ab == 0x00C5);
g_assert_true (hb_unicode_compose (uf, 0x006F, 0x0302, &ab) && ab == 0x00F4);
g_assert_true (hb_unicode_compose (uf, 0x1E63, 0x0307, &ab) && ab == 0x1E69);
g_assert_true (hb_unicode_compose (uf, 0x0073, 0x0323, &ab) && ab == 0x1E63);
g_assert_true (hb_unicode_compose (uf, 0x0064, 0x0307, &ab) && ab == 0x1E0B);
g_assert_true (hb_unicode_compose (uf, 0x0064, 0x0323, &ab) && ab == 0x1E0D);
/* Hangul */
g_assert (hb_unicode_compose (uf, 0xD4CC, 0x11B6, &ab) && ab == 0xD4DB);
g_assert (hb_unicode_compose (uf, 0x1111, 0x1171, &ab) && ab == 0xD4CC);
g_assert (hb_unicode_compose (uf, 0xCE20, 0x11B8, &ab) && ab == 0xCE31);
g_assert (hb_unicode_compose (uf, 0x110E, 0x1173, &ab) && ab == 0xCE20);
g_assert_true (hb_unicode_compose (uf, 0xD4CC, 0x11B6, &ab) && ab == 0xD4DB);
g_assert_true (hb_unicode_compose (uf, 0x1111, 0x1171, &ab) && ab == 0xD4CC);
g_assert_true (hb_unicode_compose (uf, 0xCE20, 0x11B8, &ab) && ab == 0xCE31);
g_assert_true (hb_unicode_compose (uf, 0x110E, 0x1173, &ab) && ab == 0xCE20);
g_assert (!hb_unicode_compose (uf, 0xAC00, 0x11A7, &ab));
g_assert (hb_unicode_compose (uf, 0xAC00, 0x11A8, &ab) && ab == 0xAC01);
g_assert (!hb_unicode_compose (uf, 0xAC01, 0x11A8, &ab));
g_assert_true (!hb_unicode_compose (uf, 0xAC00, 0x11A7, &ab));
g_assert_true (hb_unicode_compose (uf, 0xAC00, 0x11A8, &ab) && ab == 0xAC01);
g_assert_true (!hb_unicode_compose (uf, 0xAC01, 0x11A8, &ab));
/* Test decompose() */
/* Not decomposable */
g_assert (!hb_unicode_decompose (uf, 0x0041, &a, &b) && a == 0x0041 && b == 0);
g_assert (!hb_unicode_decompose (uf, 0xFB01, &a, &b) && a == 0xFB01 && b == 0);
g_assert (!hb_unicode_decompose (uf, 0x1F1EF, &a, &b) && a == 0x1F1EF && b == 0);
g_assert_true (!hb_unicode_decompose (uf, 0x0041, &a, &b) && a == 0x0041 && b == 0);
g_assert_true (!hb_unicode_decompose (uf, 0xFB01, &a, &b) && a == 0xFB01 && b == 0);
g_assert_true (!hb_unicode_decompose (uf, 0x1F1EF, &a, &b) && a == 0x1F1EF && b == 0);
/* Singletons */
g_assert (hb_unicode_decompose (uf, 0x212B, &a, &b) && a == 0x00C5 && b == 0);
g_assert (hb_unicode_decompose (uf, 0x2126, &a, &b) && a == 0x03A9 && b == 0);
g_assert_true (hb_unicode_decompose (uf, 0x212B, &a, &b) && a == 0x00C5 && b == 0);
g_assert_true (hb_unicode_decompose (uf, 0x2126, &a, &b) && a == 0x03A9 && b == 0);
/* Non-starter pairs decompose, but not compose */
g_assert (hb_unicode_decompose (uf, 0x0344, &a, &b) && a == 0x0308 && b == 0x0301);
g_assert (hb_unicode_decompose (uf, 0x0F73, &a, &b) && a == 0x0F71 && b == 0x0F72);
g_assert_true (hb_unicode_decompose (uf, 0x0344, &a, &b) && a == 0x0308 && b == 0x0301);
g_assert_true (hb_unicode_decompose (uf, 0x0F73, &a, &b) && a == 0x0F71 && b == 0x0F72);
/* Pairs */
g_assert (hb_unicode_decompose (uf, 0x00C5, &a, &b) && a == 0x0041 && b == 0x030A);
g_assert (hb_unicode_decompose (uf, 0x00F4, &a, &b) && a == 0x006F && b == 0x0302);
g_assert (hb_unicode_decompose (uf, 0x1E69, &a, &b) && a == 0x1E63 && b == 0x0307);
g_assert (hb_unicode_decompose (uf, 0x1E63, &a, &b) && a == 0x0073 && b == 0x0323);
g_assert (hb_unicode_decompose (uf, 0x1E0B, &a, &b) && a == 0x0064 && b == 0x0307);
g_assert (hb_unicode_decompose (uf, 0x1E0D, &a, &b) && a == 0x0064 && b == 0x0323);
g_assert_true (hb_unicode_decompose (uf, 0x00C5, &a, &b) && a == 0x0041 && b == 0x030A);
g_assert_true (hb_unicode_decompose (uf, 0x00F4, &a, &b) && a == 0x006F && b == 0x0302);
g_assert_true (hb_unicode_decompose (uf, 0x1E69, &a, &b) && a == 0x1E63 && b == 0x0307);
g_assert_true (hb_unicode_decompose (uf, 0x1E63, &a, &b) && a == 0x0073 && b == 0x0323);
g_assert_true (hb_unicode_decompose (uf, 0x1E0B, &a, &b) && a == 0x0064 && b == 0x0307);
g_assert_true (hb_unicode_decompose (uf, 0x1E0D, &a, &b) && a == 0x0064 && b == 0x0323);
/* Hangul */
g_assert (hb_unicode_decompose (uf, 0xD4DB, &a, &b) && a == 0xD4CC && b == 0x11B6);
g_assert (hb_unicode_decompose (uf, 0xD4CC, &a, &b) && a == 0x1111 && b == 0x1171);
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);
g_assert_true (hb_unicode_decompose (uf, 0xD4DB, &a, &b) && a == 0xD4CC && b == 0x11B6);
g_assert_true (hb_unicode_decompose (uf, 0xD4CC, &a, &b) && a == 0x1111 && b == 0x1171);
g_assert_true (hb_unicode_decompose (uf, 0xCE31, &a, &b) && a == 0xCE20 && b == 0x11B8);
g_assert_true (hb_unicode_decompose (uf, 0xCE20, &a, &b) && a == 0x110E && b == 0x1173);
}

View file

@ -78,11 +78,11 @@ test_get_var_get_axis_infos (void)
unsigned c = 1;
g_assert_cmpint (hb_ot_var_get_axis_infos (face, 0, &c, &info), ==, 2);
g_assert (info.tag == HB_TAG ('w','g','h','t'));
g_assert_true (info.tag == HB_TAG ('w','g','h','t'));
g_assert_cmpint (c, ==, 1);
hb_ot_var_get_axis_infos (face, 1, &c, &info);
g_assert (info.tag == HB_TAG ('w','d','t','h'));
g_assert_true (info.tag == HB_TAG ('w','d','t','h'));
g_assert_cmpint (c, ==, 1);
hb_ot_var_get_axis_infos (face, 2, &c, &info);

View file

@ -42,32 +42,32 @@ test_version (void)
g_assert_cmpint (micro, ==, HB_VERSION_MICRO);
s = g_strdup_printf ("%u.%u.%u", major, minor, micro);
g_assert (0 == strcmp (HB_VERSION_STRING, s));
g_assert_true (0 == strcmp (HB_VERSION_STRING, s));
g_free (s);
g_assert (0 == strcmp (HB_VERSION_STRING, hb_version_string ()));
g_assert_true (0 == strcmp (HB_VERSION_STRING, hb_version_string ()));
g_assert (HB_VERSION_ATLEAST (major, minor, micro));
g_assert_true (HB_VERSION_ATLEAST (major, minor, micro));
if (major)
g_assert (HB_VERSION_ATLEAST (major-1, minor, micro));
g_assert_true (HB_VERSION_ATLEAST (major-1, minor, micro));
if (minor)
g_assert (HB_VERSION_ATLEAST (major, minor-1, micro));
g_assert_true (HB_VERSION_ATLEAST (major, minor-1, micro));
if (micro)
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_true (HB_VERSION_ATLEAST (major, minor, micro-1));
g_assert_true (!HB_VERSION_ATLEAST (major+1, minor, micro));
g_assert_true (!HB_VERSION_ATLEAST (major, minor+1, micro));
g_assert_true (!HB_VERSION_ATLEAST (major, minor, micro+1));
g_assert_true (!HB_VERSION_ATLEAST (major, minor, micro+1));
g_assert (hb_version_atleast (major, minor, micro));
g_assert_true (hb_version_atleast (major, minor, micro));
if (major)
g_assert (hb_version_atleast (major-1, minor, micro));
g_assert_true (hb_version_atleast (major-1, minor, micro));
if (minor)
g_assert (hb_version_atleast (major, minor-1, micro));
g_assert_true (hb_version_atleast (major, minor-1, micro));
if (micro)
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_true (hb_version_atleast (major, minor, micro-1));
g_assert_true (!hb_version_atleast (major+1, minor, micro));
g_assert_true (!hb_version_atleast (major, minor+1, micro));
g_assert_true (!hb_version_atleast (major, minor, micro+1));
}
int

16
test/fuzzing/glob.py Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env python3
import sys
import os
if len(sys.argv) < 2:
print("Usage: python glob.py [DIR]...")
sys.exit(1)
for arg in sys.argv[1:]:
if os.path.isdir(arg):
for dirpath, dirnames, filenames in os.walk(arg):
for filename in filenames:
print(os.path.join(dirpath, filename))
elif os.path.isfile(arg):
print(arg)

View file

@ -5,6 +5,8 @@
int main (int argc, char **argv)
{
printf ("TAP version 14\n");
for (int i = 1; i < argc; i++)
{
hb_blob_t *blob = hb_blob_create_from_file_or_fail (argv[i]);
@ -12,11 +14,16 @@ int main (int argc, char **argv)
unsigned len = 0;
const char *font_data = hb_blob_get_data (blob, &len);
printf ("%s (%u bytes)\n", argv[i], len);
printf ("# %s (%u bytes)\n", argv[i], len);
LLVMFuzzerTestOneInput ((const uint8_t *) font_data, len);
printf ("ok %d - %s\n", i, argv[i]);
hb_blob_destroy (blob);
}
printf ("1..%d\n", argc - 1);
return 0;
}

View file

@ -6,6 +6,7 @@ tests = [
'hb-repacker-fuzzer.cc',
]
# Build the binaries
foreach file_name : tests
test_name = file_name.split('.')[0]
@ -34,43 +35,90 @@ foreach file_name : tests
set_variable('@0@_exe'.format(test_name.underscorify()), exe)
endforeach
test('shape-fuzzer', find_program('run-fuzzer-tests.py'),
args: [
glob_cmd = find_program('glob.py', required: true)
fonts_glob = run_command(glob_cmd, meson.current_source_dir() / 'fonts', check:true).stdout().strip().split('\n')
subset_fonts_glob = run_command(glob_cmd, meson.current_source_dir() / '..' / 'subset' / 'data' / 'fonts', check:true).stdout().strip().split('\n')
graphs_glob = run_command(glob_cmd, meson.current_source_dir() / 'graphs', check:true).stdout().strip().split('\n')
sets_glob = run_command(glob_cmd, meson.current_source_dir() / 'sets', check:true).stdout().strip().split('\n')
# Chunk the glob lists to avoid command line length limits, and for parallelization
chunk_size = 64
foreach glob_name : ['fonts_glob', 'subset_fonts_glob', 'graphs_glob', 'sets_glob']
glob = get_variable(glob_name)
chunks = []
chunk = []
foreach item : glob
if chunk.length() >= chunk_size
chunks += [chunk]
chunk = []
endif
chunk += [item]
endforeach
if chunk.length() > 0
chunks += [chunk]
endif
set_variable('@0@_chunks'.format(glob_name), chunks)
endforeach
# Run fuzzers
i = 0
foreach chunk : fonts_glob_chunks
test('shape-fuzzer-chunk-@0@'.format(i),
hb_shape_fuzzer_exe,
meson.current_source_dir() / 'fonts',
],
depends: [hb_shape_fuzzer_exe, libharfbuzz, libharfbuzz_subset],
workdir: meson.current_build_dir() / '..' / '..',
priority: 1,
suite: ['fuzzing'],
)
args: chunk,
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: ['fuzzing'],
)
i += 1
endforeach
test('subset-fuzzer', find_program('run-fuzzer-tests.py'),
args: [
hb_subset_fuzzer_exe,
meson.current_source_dir() / 'fonts',
meson.current_source_dir() / '..' / 'subset' / 'data' / 'fonts',
],
workdir: meson.current_build_dir() / '..' / '..',
priority: 1,
suite: ['fuzzing'],
)
test('repacker-fuzzer', find_program('run-fuzzer-tests.py'),
args: [
hb_repacker_fuzzer_exe,
meson.current_source_dir() / 'graphs',
],
workdir: meson.current_build_dir() / '..' / '..',
priority: 1,
suite: ['fuzzing'],
)
test('draw-fuzzer', find_program('run-fuzzer-tests.py'),
args: [
i = 0
foreach chunk : fonts_glob_chunks
test('draw-fuzzer-chunk-@0@'.format(i),
hb_draw_fuzzer_exe,
meson.current_source_dir() / 'fonts',
],
workdir: meson.current_build_dir() / '..' / '..',
suite: ['fuzzing'],
)
args: chunk,
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: ['fuzzing'],
)
i += 1
endforeach
i = 0
foreach chunk : fonts_glob_chunks + subset_fonts_glob_chunks
test('subset-fuzzer-chunk-@0@'.format(i),
hb_subset_fuzzer_exe,
args: chunk,
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: ['fuzzing'],
)
i += 1
endforeach
i = 0
foreach chunk : graphs_glob_chunks
test('repacker-fuzzer-chunk-@0@'.format(i),
hb_repacker_fuzzer_exe,
args: chunk,
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: ['fuzzing'],
)
i += 1
endforeach
i = 0
foreach chunk : sets_glob_chunks
test('set-fuzzer-chunk-@0@'.format(i),
hb_set_fuzzer_exe,
args: chunk,
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: ['fuzzing'],
)
i += 1
endforeach

View file

@ -1,79 +0,0 @@
#!/usr/bin/env python3
import pathlib
import subprocess
import os
import sys
import tempfile
EXE_WRAPPER = os.environ.get("MESON_EXE_WRAPPER")
def run_command(command):
"""
Run a command, capturing potentially large output in a temp file.
Returns (output_string, exit_code).
"""
global EXE_WRAPPER
if EXE_WRAPPER:
command = [EXE_WRAPPER] + command
with tempfile.TemporaryFile() as tempf:
p = subprocess.Popen(command, stdout=tempf, stderr=tempf)
p.wait()
tempf.seek(0)
output = tempf.read().decode("utf-8", errors="replace").strip()
return output, p.returncode
def chunkify(lst, chunk_size=64):
"""
Yield successive chunk_size-sized slices from lst.
"""
for i in range(0, len(lst), chunk_size):
yield lst[i : i + chunk_size]
def main():
assert len(sys.argv) > 2, "Please provide fuzzer binary and fonts directory paths."
fuzzer = pathlib.Path(sys.argv[1])
assert fuzzer.is_file(), f"Fuzzer binary not found: {fuzzer}"
print("Using fuzzer:", fuzzer)
# Gather all test files
files_to_test = []
for fonts_dir in sys.argv[2:]:
fonts_dir = pathlib.Path(fonts_dir)
assert fonts_dir.is_dir(), f"Fonts directory not found: {fonts_dir}"
test_files = [str(f) for f in fonts_dir.iterdir() if f.is_file()]
assert test_files, f"No files found in {fonts_dir}"
files_to_test += test_files
if not files_to_test:
print("No test files found")
sys.exit(0)
fails = 0
batch_index = 0
for chunk in chunkify(files_to_test):
batch_index += 1
cmd_line = [fuzzer] + chunk
output, returncode = run_command(cmd_line)
if output:
print(output)
if returncode != 0:
print(f"Failure in batch #{batch_index}")
fails += 1
if fails > 0:
sys.exit(f"{fails} fuzzer batch(es) failed.")
print("All fuzzer tests passed successfully.")
if __name__ == "__main__":
main()

View file

@ -1,4 +1,4 @@
text_rendering_tests = [
text_rendering_tests_tests = [
'AVAR-1.tests',
'CFF-1.tests',
'CFF-2.tests',
@ -77,7 +77,7 @@ text_rendering_tests = [
'SHKNDA-1.tests',
]
disabled_text_rendering_tests = [
disabled_text_rendering_tests_tests = [
'CMAP-3.tests',
'SHARAN-1.tests',
'SHBALI-1.tests',

View file

@ -118,9 +118,9 @@ subprocess.run([git, "add", "tests"], check=True)
with open("meson.build", "w") as f:
f.write(
"\n".join(
["text_rendering_tests = ["]
["text_rendering_tests_tests = ["]
+ [" '%s'," % x.split("tests/")[1] for x in tests]
+ ["]", "", "disabled_text_rendering_tests = ["]
+ ["]", "", "disabled_text_rendering_tests_tests = ["]
+ [" '%s'," % x.split("tests/")[1] for x in disabled_tests]
+ ["]", ""]
)

View file

@ -12,44 +12,25 @@ env.set('HAVE_CORETEXT', '@0@'.format(conf.get('HAVE_CORETEXT', 0)))
env.set('HAVE_DIRECTWRITE', '@0@'.format(conf.get('HAVE_DIRECTWRITE', 0)))
env.set('HAVE_UNISCRIBE', '@0@'.format(conf.get('HAVE_UNISCRIBE', 0)))
foreach file_name : in_house_tests
test_name = file_name.split('.')[0]
test(test_name, shape_run_tests_py,
sets = ['in-house', 'aots', 'text-rendering-tests']
foreach set : sets
# in-house -> in_house_tests, aots -> aots_tests, text-rendering-tests -> text_rendering_tests
varname = '@0@_tests'.format(set.underscorify())
tests = get_variable(varname)
file_names = []
foreach test : tests
file_name = meson.current_source_dir() / 'data' / set / 'tests' / test
file_names += [file_name]
endforeach
test(set, shape_run_tests_py,
args: [
hb_shape,
meson.current_source_dir() / 'data' / 'in-house' / 'tests' / file_name,
file_names,
],
protocol: 'tap',
#verbose: true,
env: env,
workdir: meson.current_build_dir() / '..' / '..',
suite: ['shape', 'in-house'],
)
endforeach
foreach file_name : aots_tests
test_name = file_name.split('.')[0]
test(test_name, shape_run_tests_py,
args: [
hb_shape,
meson.current_source_dir() / 'data' / 'aots' / 'tests' / file_name,
],
env: env,
workdir: meson.current_build_dir() / '..' / '..',
suite: ['shape', 'aots'],
)
endforeach
foreach file_name : text_rendering_tests
test_name = file_name.split('.')[0]
test(test_name, shape_run_tests_py,
args: [
hb_shape,
meson.current_source_dir() / 'data' / 'text-rendering-tests' / 'tests' / file_name,
],
env: env,
workdir: meson.current_build_dir() / '..' / '..',
suite: ['shape', 'text-rendering-tests'],
suite: ['shape', set],
)
endforeach

View file

@ -2,6 +2,8 @@
import sys, os, subprocess, hashlib
print("TAP version 14")
args = sys.argv[1:]
verbose = False
@ -46,7 +48,7 @@ def shape_cmd(command, shape_process, verbose=False):
shape_process = open_shape_batch_process()
if verbose:
print(hb_shape + " " + " ".join(command))
print("# " + hb_shape + " " + " ".join(command))
shape_process.stdin.write((";".join(command) + "\n").encode("utf-8"))
shape_process.stdin.flush()
return shape_process.stdout.readline().decode("utf-8").strip()
@ -102,19 +104,20 @@ for what in ["shaper", "face-loader", "font-funcs"]:
whats = plural(what)
var_name = supported_whats_var_name(what)
globals()[var_name] = what_list
print(f"Supported {whats}: {what_list}")
print(f"# Supported {whats}: {what_list}")
# If running under Wine and not native dlls, make the respective shapers unavailable.
if os.environ.get("WINEPATH"):
overrides = os.environ.get("WINEDLLOVERRIDES", "").lower()
if "directwrite" in supported_shapers and overrides.find("dwrite") == -1:
supported_shapers.remove("directwrite")
print("Skipping DirectWrite shaper under Wine.")
print("# Skipping DirectWrite shaper under Wine.")
if "uniscribe" in supported_shapers and overrides.find("usp10") == -1:
supported_shapers.remove("uniscribe")
print("Skipping Uniscribe shaper under Wine.")
print("# Skipping Uniscribe shaper under Wine.")
number = 0
passes = 0
fails = 0
skips = 0
@ -124,9 +127,9 @@ if not len(args):
for filename in args:
if filename == "-":
print("Running tests from standard input")
print("# Running tests from standard input")
else:
print("Running tests in " + filename)
print("# Running tests in " + filename)
if filename == "-":
f = sys.stdin
@ -178,11 +181,11 @@ for filename in args:
values = [v for v in values if v in supported]
var_name = all_whats_var_name(what)
print(f"Setting {whats} to test to {values}")
print(f"# Setting {whats} to test to {values}")
globals()[var_name] = values
consumed = True
if consumed:
print(line)
print("#", line)
continue
else:
print("Unrecognized directive: %s" % line, file=sys.stderr)
@ -201,15 +204,15 @@ for filename in args:
if expected_hash:
actual_hash = hashlib.sha1(ff.read()).hexdigest().strip()
if actual_hash != expected_hash:
skips += 1
print(
"different version of %s found; Expected hash %s, got %s; skipping."
"# Different version of %s found; Expected hash %s, got %s; skipping."
% (fontfile, expected_hash, actual_hash)
)
skips += 1
continue
except IOError:
print("%s not found, skip." % fontfile)
skips += 1
print("# %s not found, skip." % fontfile)
continue
else:
cwd = os.path.dirname(filename)
@ -217,7 +220,7 @@ for filename in args:
if comment:
if verbose:
print('# %s "%s" --unicodes %s' % (hb_shape, fontfile, unicodes))
print('# # %s "%s" --unicodes %s' % (hb_shape, fontfile, unicodes))
continue
skip_test = False
@ -236,7 +239,11 @@ for filename in args:
backend = next(it)
if backend not in supported_whats(what):
skips += 1
print(f"Skipping test with {what}={backend}.")
number += 1
print(
f"ok {number} - {fontfile} # skip {what}={backend} not supported"
)
print(f"# Skipping test with {what}={backend}.")
skip_test = True
break
what = what.replace("-", "_")
@ -253,6 +260,7 @@ for filename in args:
for shaper in [shaper] if shaper else all_whats("shaper"):
for font_funcs in [font_funcs] if font_funcs else all_whats("font-funcs"):
number += 1
extra_options = []
if shaper:
@ -276,6 +284,7 @@ for filename in args:
if glyphs_expected == "*":
passes += 1
print(f"ok {number} - {fontfile}")
continue
final_glyphs = glyphs
@ -300,33 +309,31 @@ for filename in args:
# If the removal of glyph_ids failed, fail the test.
# https://github.com/harfbuzz/harfbuzz/issues/5169
if not final_glyphs_expected or final_glyphs != final_glyphs_expected:
print(hb_shape + " " + " ".join(cmd), file=sys.stderr)
print("Actual: " + glyphs, file=sys.stderr)
print("Expected: " + glyphs_expected, file=sys.stderr)
fails += 1
cmd = hb_shape + " " + " ".join(cmd)
print(f"not ok {number} - {cmd}")
print(" ---", file=sys.stderr)
print(' test_file: "' + filename + '"', file=sys.stderr)
print(' cmd: "' + cmd + '"', file=sys.stderr)
print(' actual: "' + glyphs + '"', file=sys.stderr)
print(' expected: "' + glyphs_expected + '"', file=sys.stderr)
if final_glyphs != glyphs:
print(
"Actual (no glyph names): " + final_glyphs,
file=sys.stderr,
' actual_gids: "' + final_glyphs + '"', file=sys.stderr
)
print(
"Expected (no glyph names): " + final_glyphs_expected,
' expected_gids: "' + final_glyphs_expected + '"',
file=sys.stderr,
)
fails += 1
print(" ...", file=sys.stderr)
else:
passes += 1
print(f"ok {number} - {fontfile}")
print(
"%d tests passed; %d failed; %d skipped." % (passes, fails, skips), file=sys.stderr
)
print("1..%d" % number)
print("# %d tests passed; %d failed; %d skipped." % (passes, fails, skips))
if not (fails + passes):
print("No tests ran.")
print("# No tests ran.")
elif not (fails + skips):
print("All tests passed.")
if fails:
sys.exit(1)
elif passes:
sys.exit(0)
else:
sys.exit(77)
print("# All tests passed.")

View file

@ -111,6 +111,7 @@ foreach t : tests
# ideally better to break and let meson handles them in parallel
timeout: 500,
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: 'subset',
)
endforeach
@ -126,6 +127,7 @@ foreach t : repack_tests
meson.current_source_dir() / 'data' / 'repack_tests' / fname,
],
workdir: meson.current_build_dir() / '..' / '..',
protocol: 'tap',
suite: ['subset', 'repack'],
)
endforeach

View file

@ -17,8 +17,8 @@ from repack_test import RepackTest
try:
from fontTools.ttLib import TTFont
except ImportError:
print("fonttools is not present, skipping test.")
sys.exit(77)
print("# fonttools is not present, skipping test.")
sys.exit()
ots_sanitize = shutil.which("ots-sanitize")
@ -27,7 +27,7 @@ EXE_WRAPPER = os.environ.get("MESON_EXE_WRAPPER")
def subset_cmd(command):
global hb_subset, process
print(hb_subset + " " + " ".join(command))
print("# " + hb_subset + " " + " ".join(command))
process.stdin.write((";".join(command) + "\n").encode("utf-8"))
process.stdin.flush()
return process.stdout.readline().decode("utf-8").strip()
@ -43,11 +43,20 @@ def cmd(command):
def fail_test(test, cli_args, message):
global fails
fails += 1
print("ERROR: %s" % message)
print("Test State:")
print(" test.font_name %s" % test.font_name)
print(" test.test_path %s" % os.path.abspath(test.test_path))
return 1
print("not ok -", test)
print(" ---", file=sys.stderr)
print(" message: \"%s\"" % message, file=sys.stderr)
print(" test.font_name: \"%s\"" % test.font_name)
print(" test.test_path: \"%s\"" % os.path.abspath(test.test_path))
print(" ...", file=sys.stderr)
return False
def run_test(test, should_check_ots):
@ -58,7 +67,7 @@ def run_test(test, should_check_ots):
"--unicodes=%s" % test.codepoints_string(),
"--drop-tables-=GPOS,GSUB,GDEF",
]
print(" ".join(cli_args))
print("#", " ".join(cli_args))
ret = subset_cmd(cli_args)
if ret != "success":
@ -72,16 +81,16 @@ def run_test(test, should_check_ots):
return fail_test(test, cli_args, "ttx failed to parse the result")
if should_check_ots:
print("Checking output with ots-sanitize.")
print("# Checking output with ots-sanitize.")
if not check_ots(out_file):
return fail_test(test, cli_args, "ots for subsetted file fails.")
return 0
return True
def has_ots():
if not ots_sanitize:
print("OTS is not present, skipping all ots checks.")
print("# OTS is not present, skipping all ots checks.")
return False
return True
@ -89,7 +98,7 @@ def has_ots():
def check_ots(path):
ots_report, returncode = cmd([ots_sanitize, path])
if returncode:
print("OTS Failure: %s" % ots_report)
print("# OTS Failure: %s" % ots_report)
return False
return True
@ -102,8 +111,6 @@ hb_subset, args = args[0], args[1:]
if len(args) != 1:
sys.exit("No tests supplied.")
has_ots = has_ots()
batch_cmd = [hb_subset, "--batch"]
if EXE_WRAPPER:
batch_cmd = [EXE_WRAPPER] + batch_cmd
@ -111,6 +118,10 @@ process = subprocess.Popen(
batch_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stdout
)
print("TAP version 14")
has_ots = has_ots()
fails = 0
path = args[0]
@ -119,13 +130,17 @@ if not path.endswith(".tests"):
out_dir = tempfile.mkdtemp()
number = 0
with open(path, mode="r", encoding="utf-8") as f:
# TODO(garretrieger): re-enable OTS checking.
fails += run_test(RepackTest(path, f.read()), False)
if run_test(RepackTest(path, f.read()), False):
number += 1
print("ok %d - %s" % (number, os.path.basename(path)))
print("1..%d" % number)
if fails != 0:
sys.exit("%d test(s) failed; output left in %s" % (fails, out_dir))
print("# %d test(s) failed; output left in %s" % (fails, out_dir))
else:
print("All tests passed.")
print("# All tests passed.")
shutil.rmtree(out_dir)

View file

@ -29,7 +29,7 @@ def subset_cmd(command):
if subset_process.poll() is not None:
subset_process = open_subset_batch_process()
print(hb_subset + " " + " ".join(command))
print("# " + hb_subset + " " + " ".join(command))
subset_process.stdin.write((";".join(command) + "\n").encode("utf-8"))
subset_process.stdin.flush()
return subset_process.stdout.readline().decode("utf-8").strip()
@ -45,19 +45,28 @@ def cmd(command):
def fail_test(test, cli_args, message):
print("ERROR: %s" % message)
print("Test State:")
print(" test.font_path %s" % os.path.abspath(test.font_path))
print(" test.profile_path %s" % os.path.abspath(test.profile_path))
print(" test.unicodes %s" % test.unicodes())
global fails
fails += 1
expected_file = os.path.join(
test_suite.get_output_directory(), test.get_font_name()
)
print(" expected_file %s" % os.path.abspath(expected_file))
return 1
print("not ok -", test)
print(" ---", file=sys.stderr)
print(" message: \"%s\"" % message, file=sys.stderr)
print(" test.font_path: \"%s\"" % os.path.abspath(test.font_path), file=sys.stderr)
print(" test.profile_path: \"%s\"" % os.path.abspath(test.profile_path), file=sys.stderr)
print(" test.unicodes: \"%s\"" % test.unicodes(), file=sys.stderr)
print(" expected_file: \"%s\"" % os.path.abspath(expected_file), file=sys.stderr)
print(" ...", file=sys.stderr)
return False
def run_test(test, should_check_ots, preprocess):
global number
number += 1
out_file = os.path.join(
out_dir, test.get_font_name() + "-subset" + test.get_font_extension()
)
@ -99,13 +108,13 @@ def run_test(test, should_check_ots, preprocess):
if expected_contents == actual_contents:
if should_check_ots:
print("Checking output with ots-sanitize.")
print("# Checking output with ots-sanitize.")
if not check_ots(out_file):
return fail_test(test, cli_args, "ots for subsetted file fails.")
return 0
return True
if TTFont is None:
print("fonttools is not present, skipping TTX diff.")
print("# fonttools is not present, skipping TTX diff.")
return fail_test(test, cli_args, "hash for expected and actual does not match.")
with io.StringIO() as fp:
@ -142,7 +151,7 @@ def run_test(test, should_check_ots, preprocess):
def has_ots():
if not ots_sanitize:
print("OTS is not present, skipping all ots checks.")
print("# OTS is not present, skipping all ots checks.")
return False
return True
@ -150,7 +159,7 @@ def has_ots():
def check_ots(path):
ots_report, returncode = cmd([ots_sanitize, path])
if returncode:
print("OTS Failure: %s" % ots_report)
print("# OTS Failure: %s" % ots_report)
return False
return True
@ -163,6 +172,8 @@ hb_subset, args = args[0], args[1:]
if not len(args):
sys.exit("No tests supplied.")
print("TAP version 14")
has_ots = has_ots()
env = os.environ.copy()
@ -189,19 +200,23 @@ def open_subset_batch_process():
subset_process = open_subset_batch_process()
out_dir = tempfile.mkdtemp()
number = 0
fails = 0
for path in args:
with open(path, mode="r", encoding="utf-8") as f:
print("Running tests in " + path)
print("# Running tests in " + path)
test_suite = SubsetTestSuite(path, f.read())
for test in test_suite.tests():
# Tests are run with and without preprocessing, results should be the
# same between them.
fails += run_test(test, has_ots, False)
fails += run_test(test, has_ots, True)
for preprocess in [False, True]:
if run_test(test, has_ots, preprocess):
print("ok %d - %s" % (number, test))
print("1..%d" % number)
if fails != 0:
sys.exit("%d test(s) failed; output left in %s" % (fails, out_dir))
print("# %d test(s) failed; output left in %s" % (fails, out_dir), file=sys.stderr)
else:
print("All tests passed.")
print("# All tests passed.")
shutil.rmtree(out_dir)