[set] don't allow -1 (HB_SET_VALUE_INVALID) to be inserted into a hb_set_t.
Add tests that check all of the addition methods.
This commit is contained in:
parent
a84cae424d
commit
8d8bcde8cf
|
@ -194,7 +194,7 @@ struct hb_bit_set_t
|
||||||
unsigned int end = major_start (m + 1);
|
unsigned int end = major_start (m + 1);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (v || page) /* The v check is to optimize out the page check if v is true. */
|
if (g != INVALID && (v || page)) /* The v check is to optimize out the page check if v is true. */
|
||||||
page->set (g, v);
|
page->set (g, v);
|
||||||
|
|
||||||
array = &StructAtOffsetUnaligned<T> (array, stride);
|
array = &StructAtOffsetUnaligned<T> (array, stride);
|
||||||
|
@ -238,7 +238,7 @@ struct hb_bit_set_t
|
||||||
if (g < last_g) return false;
|
if (g < last_g) return false;
|
||||||
last_g = g;
|
last_g = g;
|
||||||
|
|
||||||
if (v || page) /* The v check is to optimize out the page check if v is true. */
|
if (g != INVALID && (v || page)) /* The v check is to optimize out the page check if v is true. */
|
||||||
page->add (g);
|
page->add (g);
|
||||||
|
|
||||||
array = &StructAtOffsetUnaligned<T> (array, stride);
|
array = &StructAtOffsetUnaligned<T> (array, stride);
|
||||||
|
|
|
@ -137,5 +137,29 @@ main (int argc, char **argv)
|
||||||
assert (s.has (HB_SET_VALUE_INVALID));
|
assert (s.has (HB_SET_VALUE_INVALID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adding HB_SET_VALUE_INVALID */
|
||||||
|
{
|
||||||
|
hb_set_t s;
|
||||||
|
|
||||||
|
s.add(HB_SET_VALUE_INVALID);
|
||||||
|
assert(!s.has(HB_SET_VALUE_INVALID));
|
||||||
|
|
||||||
|
s.clear();
|
||||||
|
assert(!s.add_range(HB_SET_VALUE_INVALID - 2, HB_SET_VALUE_INVALID));
|
||||||
|
assert(!s.has(HB_SET_VALUE_INVALID));
|
||||||
|
|
||||||
|
hb_codepoint_t array[] = {(unsigned) HB_SET_VALUE_INVALID, 0, 2};
|
||||||
|
s.clear();
|
||||||
|
s.add_array(array, 3);
|
||||||
|
assert(!s.has(HB_SET_VALUE_INVALID));
|
||||||
|
assert(s.has(2));
|
||||||
|
|
||||||
|
hb_codepoint_t sorted_array[] = {0, 2, (unsigned) HB_SET_VALUE_INVALID};
|
||||||
|
s.clear();
|
||||||
|
s.add_sorted_array(sorted_array, 3);
|
||||||
|
assert(!s.has(HB_SET_VALUE_INVALID));
|
||||||
|
assert(s.has(2));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue