fixed bug & added tests
This commit is contained in:
parent
a5012e97c4
commit
173b745da8
|
@ -392,9 +392,10 @@ struct hb_set_t
|
|||
dirty ();
|
||||
unsigned int ma = get_major (a);
|
||||
unsigned int mb = get_major (b);
|
||||
/* Delete entire pages from mds through mde. */
|
||||
unsigned int mds = (a == major_start (ma))? ma: (ma + 1);
|
||||
int mde = (b + 1 == major_start (mb + 1))? (int)mb: ((int)mb - 1);
|
||||
if (ma < mds)
|
||||
if ((int)mds > mde || ma < mds)
|
||||
{
|
||||
page_t *page = page_for (a);
|
||||
if (page)
|
||||
|
|
|
@ -479,14 +479,16 @@ test_set_delrange (void)
|
|||
for (unsigned int g = 0; g < 2100; g += 10)
|
||||
hb_set_add (s, g);
|
||||
|
||||
hb_set_add (s, 512); /* edge case */
|
||||
hb_set_add (s, 2047); /* (=512*4-1) edge case */
|
||||
|
||||
hb_set_del_range (s, 55, 705);
|
||||
hb_set_del_range (s, 512, 705);
|
||||
hb_set_del_range (s, 795, 2047);
|
||||
|
||||
g_assert ( hb_set_has (s, 50));
|
||||
g_assert (!hb_set_has (s, 60));
|
||||
g_assert (!hb_set_has (s, 600));
|
||||
g_assert ( hb_set_has (s, 0));
|
||||
g_assert ( hb_set_has (s, 510));
|
||||
g_assert (!hb_set_has (s, 512));
|
||||
g_assert (!hb_set_has (s, 700));
|
||||
g_assert ( hb_set_has (s, 710));
|
||||
g_assert ( hb_set_has (s, 790));
|
||||
g_assert (!hb_set_has (s, 800));
|
||||
|
|
Loading…
Reference in New Issue