TEST(ng_charreach, caseless) { CharReach cr; cr.set('a'); ASSERT_FALSE(cr.isCaselessChar()); cr.set('A'); ASSERT_TRUE(cr.isCaselessChar()); cr.set('b'); ASSERT_FALSE(cr.isCaselessChar()); cr.set('B'); ASSERT_FALSE(cr.isCaselessChar()); }
TEST(ng_charreach, caseless2) { // Test every pair of characters. for (size_t i = 0; i < 256; i++) { ASSERT_FALSE(CharReach((unsigned char)i).isCaselessChar()); for (size_t j = 0; j < 256; j++) { CharReach cr; cr.set(i); cr.set(j); bool upper_lower = (i >= 'A' && i <= 'Z') && j == i + 0x20; bool lower_upper = (i >= 'a' && i <= 'z') && i == j + 0x20; bool caseless_pair = upper_lower | lower_upper; ASSERT_EQ(caseless_pair, cr.isCaselessChar()) << "Failed for i=" << i << ", j=" << j; } } }