#include #include #include #include #define CONSTRAINT ::yycc::constraint::Constraint namespace yycctest::constraint { template bool check(const T& value) { return false; } template T clamp(const T& value) { return value; } TEST(Constraint, Normal) { CONSTRAINT instance(check, clamp); EXPECT_TRUE(instance.support_check()); EXPECT_TRUE(instance.support_clamp()); EXPECT_FALSE(instance.check(0)); EXPECT_EQ(instance.clamp(0), 0); } TEST(Constraint, SomeNone) { { CONSTRAINT instance(check, nullptr); EXPECT_TRUE(instance.support_check()); EXPECT_FALSE(instance.support_clamp()); EXPECT_FALSE(instance.check(0)); } { CONSTRAINT instance(nullptr, clamp); EXPECT_FALSE(instance.support_check()); EXPECT_TRUE(instance.support_clamp()); EXPECT_EQ(instance.clamp(0), 0); } } TEST(Constraint, AllNone) { CONSTRAINT instance(nullptr, nullptr); EXPECT_FALSE(instance.support_check()); EXPECT_FALSE(instance.support_clamp()); } }