TEST(ng_charreach, init) { CharReach cr; ASSERT_EQ(0U, cr.count()); ASSERT_TRUE(cr.none()); ASSERT_FALSE(cr.all()); ASSERT_EQ(256U, cr.size()); }
TEST(ng_charreach, flip) { CharReach cr; ASSERT_EQ(0U, cr.count()); ASSERT_TRUE(cr.none()); cr.flip(); ASSERT_EQ(cr.size(), cr.count()); ASSERT_TRUE(cr.all()); cr.flip(); ASSERT_EQ(0U, cr.count()); ASSERT_TRUE(cr.none()); cr.flip(25); ASSERT_FALSE(cr.none()); ASSERT_FALSE(cr.all()); ASSERT_EQ(1U, cr.count()); cr.flip(); ASSERT_EQ(cr.size() - 1, cr.count()); }
TEST(ng_charreach, set) { CharReach cr; ASSERT_EQ(0U, cr.count()); ASSERT_TRUE(cr.none()); ASSERT_FALSE(cr.all()); cr.set('q'); ASSERT_EQ(1U, cr.count()); cr.setall(); ASSERT_EQ(cr.size(), cr.count()); ASSERT_TRUE(cr.all()); }
TEST(ng_charreach, clear) { CharReach cr; ASSERT_EQ(0U, cr.count()); ASSERT_TRUE(cr.none()); ASSERT_FALSE(cr.all()); cr.set('q'); cr.set('u'); cr.set('a'); cr.set('r'); cr.set('k'); ASSERT_EQ(5U, cr.count()); cr.clear('r'); ASSERT_EQ(4U, cr.count()); ASSERT_FALSE(cr.test('r')); cr.setall(); ASSERT_EQ(cr.size(), cr.count()); ASSERT_TRUE(cr.all()); cr.clear(0xff); ASSERT_FALSE(cr.all()); }
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); }