TEST(EqualsAnyConstantTest, IntTest) { for (int checked = 0; checked < 100; ++checked) { // Always false when checking against no constants. EXPECT_FALSE(EqualsAnyConstant(checked)); // Check against a single constant (using the template directly and the // macro). EXPECT_EQ(checked == 42, (EqualsAnyConstant<int, 42>(checked))); EXPECT_EQ(checked == 42, QUICKSTEP_EQUALS_ANY_CONSTANT(checked, 42)); // Check against a few constants. EXPECT_EQ((checked == 2) || (checked == 3) || (checked == 5) || (checked == 7), (EqualsAnyConstant<int, 2, 3, 5, 7>(checked))); EXPECT_EQ((checked == 2) || (checked == 3) || (checked == 5) || (checked == 7), QUICKSTEP_EQUALS_ANY_CONSTANT(checked, 2, 3, 5, 7)); // Check against exactly 8 constants. EXPECT_EQ((checked == 2) || (checked == 3) || (checked == 5) || (checked == 7) || (checked == 11) || (checked == 13) || (checked == 17) || (checked == 19), (EqualsAnyConstant<int, 2, 3, 5, 7, 11, 13, 17, 19>(checked))); EXPECT_EQ((checked == 2) || (checked == 3) || (checked == 5) || (checked == 7) || (checked == 11) || (checked == 13) || (checked == 17) || (checked == 19), QUICKSTEP_EQUALS_ANY_CONSTANT(checked, 2, 3, 5, 7, 11, 13, 17, 19)); // Check against more than 8 constants (will recursively expand templates). EXPECT_EQ((checked == 2) || (checked == 3) || (checked == 5) || (checked == 7) || (checked == 11) || (checked == 13) || (checked == 17) || (checked == 19) || (checked == 23) || (checked == 29) || (checked == 31) || (checked == 37), (EqualsAnyConstant<int, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37>(checked))); EXPECT_EQ((checked == 2) || (checked == 3) || (checked == 5) || (checked == 7) || (checked == 11) || (checked == 13) || (checked == 17) || (checked == 19) || (checked == 23) || (checked == 29) || (checked == 31) || (checked == 37), QUICKSTEP_EQUALS_ANY_CONSTANT(checked, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)); } }
bool LongType::isSafelyCoercibleFrom(const Type &original_type) const { QUICKSTEP_NULL_COERCIBILITY_CHECK(); return QUICKSTEP_EQUALS_ANY_CONSTANT(original_type.getTypeID(), kInt, kLong); }