[map] Fix equality

Ouch!
This commit is contained in:
Behdad Esfahbod 2022-11-17 14:53:00 -07:00
parent 6dfd4a16e7
commit 410c14bfa2
2 changed files with 12 additions and 2 deletions

View File

@ -258,7 +258,7 @@ struct hb_hashmap_t
if (population != other.population) return false; if (population != other.population) return false;
for (auto pair : iter ()) for (auto pair : iter ())
if (get (pair.first) != pair.second) if (other.get (pair.first) != pair.second)
return false; return false;
return true; return true;

View File

@ -249,6 +249,16 @@ main (int argc, char **argv)
m.set (1, bytes); m.set (1, bytes);
assert (m.has (1)); assert (m.has (1));
} }
/* Test equality. */
{
hb_map_t m1, m2, m3;
m1.set (1, 2);
m2.set (1, 2);
m3.set (1, 3);
assert (m1 == m2);
assert (m1 != m3);
assert (!(m2 == m3));
}
return 0; return 0;
} }