[iter] Test OT::Coverage iter

This commit is contained in:
Behdad Esfahbod 2018-12-27 16:55:18 -05:00
parent fd75d29f0f
commit 2cbf5bf3a9
3 changed files with 16 additions and 5 deletions

View File

@ -42,8 +42,12 @@ struct hb_void_t { typedef void value; };
template <typename T1, typename T2>
struct hb_pair_t
{
typedef hb_pair_t<T1, T2> pair_t;
hb_pair_t (const T1& a, const T2& b) : first (a), second (b) {}
hb_pair_t (const hb_pair_t<T1, T2>& o) : hb_pair_t (o.first, o.second) {}
hb_pair_t (const pair_t& o) : hb_pair_t (o.first, o.second) {}
bool operator == (const pair_t& o) const { return first == o.first && second == o.second; }
T1 first;
T2 second;

View File

@ -1108,7 +1108,7 @@ struct Coverage
hb_sorted_iter_t<Iter, const hb_pair_t<unsigned, hb_codepoint_t> >,
hb_iter_mixin_t<Iter, const hb_pair_t<unsigned, hb_codepoint_t> >
{
Iter (const Coverage &c_)
Iter (const Coverage &c_ = Null(Coverage))
{
memset (this, 0, sizeof (*this));
format = c_.u.format;
@ -1137,7 +1137,7 @@ struct Coverage
default: break;
}
}
typedef hb_pair_t<unsigned, hb_codepoint_t> __item_type__;
typedef const hb_pair_t<unsigned, hb_codepoint_t> __item_type__;
__item_type__ __item__ () const { return hb_pair (get_coverage (), get_glyph ()); }
hb_codepoint_t get_glyph () const
@ -1155,7 +1155,7 @@ struct Coverage
{
case 1: return u.format1.get_coverage ();
case 2: return u.format2.get_coverage ();
default:return -1;
default:return NOT_COVERED;
}
}

View File

@ -29,6 +29,7 @@
#include "hb-array.hh"
#include "hb-set.hh"
#include "hb-ot-layout-common.hh"
template <typename T>
@ -81,7 +82,7 @@ test_iterator (Iterator it)
}
template <typename Iterable> static void
test_iterable (Iterable &lst = Null(Iterable))
test_iterable (const Iterable &lst = Null(Iterable))
{
// Test that can take iterator from.
test_iterator (lst.iter ());
@ -112,5 +113,11 @@ main (int argc, char **argv)
hb_sorted_array_t<int> sa;
test_iterable (sa);
test_iterable<hb_array_t<int> > ();
test_iterable<hb_sorted_array_t<const int> > ();
test_iterable<hb_vector_t<float> > ();
test_iterable<hb_set_t> ();
test_iterable<OT::Coverage> ();
return 0;
}