TEST(ng_charreach, setRange) { // Exhaustive test: every possible contiguous range. for (unsigned range = 0; range < 256; range++) { for (unsigned from = 0; from < 256 - range; from++) { unsigned to = from + range; CharReach cr; cr.setRange(from, to); ASSERT_EQ(from, cr.find_first()); ASSERT_EQ(to, cr.find_last()); ASSERT_EQ(range + 1, cr.count()); } } }
TEST(ng_charreach, find_last) { CharReach cr; cr.set('a'); ASSERT_EQ(cr.find_last(), (size_t)'a'); cr.set('b'); ASSERT_EQ(cr.find_last(), (size_t)'b'); cr.set(192); ASSERT_EQ(cr.find_last(), (size_t)192); cr.set(207); ASSERT_EQ(cr.find_last(), (size_t)207); cr.set(223); ASSERT_EQ(cr.find_last(), (size_t)223); cr.set(255); ASSERT_EQ(cr.find_last(), (size_t)255); cr.clear(); ASSERT_EQ(cr.find_last(), cr.size()); cr.set(0); ASSERT_EQ(cr.find_last(), (size_t)0); cr.set(1); ASSERT_EQ(cr.find_last(), (size_t)1); }