mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-23 16:01:07 +01:00
[set] Reject unequal populations when comparing mixed inversion (#6329)
The mixed-inversion equality path compares zipped iterators, which stop at the shorter set. An empty set therefore compares equal to a full inverted set, as does any matching finite prefix. Check populations before comparing members and add regression coverage for empty sets and matching prefixes in both argument orders. Validation: meson test -C build (261 passed, 1 skipped). Assisted-by: OpenAI Codex
This commit is contained in:
1 parent
4981dcc115
commit
c22ae24405
2 files changed
+29
No files matched your search
@@ -191,6 +191,9 @@ struct hb_bit_set_invertible_t
|
||||
return s.is_equal (other.s);
|
||||
else
|
||||
{
|
||||
if (get_population () != other.get_population ())
|
||||
return false;
|
||||
|
||||
/* TODO Add iter_ranges() and use here. */
|
||||
auto it1 = iter ();
|
||||
auto it2 = other.iter ();
|
||||
|
||||
@@ -1024,6 +1024,31 @@ test_set_inverted_equality (void)
|
||||
hb_set_destroy (b);
|
||||
}
|
||||
|
||||
static void
|
||||
test_set_mixed_inversion_equality (void)
|
||||
{
|
||||
hb_set_t *a = hb_set_create ();
|
||||
hb_set_t *b = hb_set_create ();
|
||||
hb_set_invert (b);
|
||||
|
||||
/* Empty and full sets have the same (empty) zipped prefix. */
|
||||
g_assert_false (hb_set_is_equal (a, b));
|
||||
g_assert_false (hb_set_is_equal (b, a));
|
||||
|
||||
/* Matching initial members do not imply equal sets. */
|
||||
hb_set_add_range (a, 0, 10);
|
||||
g_assert_false (hb_set_is_equal (a, b));
|
||||
g_assert_false (hb_set_is_equal (b, a));
|
||||
|
||||
hb_set_del_range (b, 0, 4);
|
||||
hb_set_del_range (a, 0, 4);
|
||||
g_assert_false (hb_set_is_equal (a, b));
|
||||
g_assert_false (hb_set_is_equal (b, a));
|
||||
|
||||
hb_set_destroy (a);
|
||||
hb_set_destroy (b);
|
||||
}
|
||||
|
||||
static void
|
||||
test_set_intersects (void)
|
||||
{
|
||||
@@ -1438,6 +1463,7 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_set_inverted_iteration_next);
|
||||
hb_test_add (test_set_inverted_iteration_prev);
|
||||
hb_test_add (test_set_inverted_equality);
|
||||
hb_test_add (test_set_mixed_inversion_equality);
|
||||
hb_test_add (test_set_intersects);
|
||||
hb_test_add (test_set_inverted_operations);
|
||||
|
||||
|
||||
Reference in new issue
Block a user