diff --git a/src/hb-bit-set-invertible.hh b/src/hb-bit-set-invertible.hh index 089c73c2c..5d61adc35 100644 --- a/src/hb-bit-set-invertible.hh +++ b/src/hb-bit-set-invertible.hh @@ -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 (); diff --git a/test/api/test-set.c b/test/api/test-set.c index 295e17580..3f29f1d4d 100644 --- a/test/api/test-set.c +++ b/test/api/test-set.c @@ -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);