我有以下枚举:
namespace Country {
enum {
ITALY = 1,
SPAIN = 2
};
}
以下UnitTest ++测试:
TEST(something) {
CHECK_EQUAL(Country::SPAIN, object.getCountry(1)); // getCountry returns int
}
这不起作用。我以为Country::SPAIN
会自动转换为int 2,但我得到了这个错误:
error: no matching function for call to ‘CheckEqual(UnitTest::TestResults&, Country::<anonymous enum>, int, UnitTest::TestDetails)’
答案 0 :(得分:1)
将枚举转换为int
自己:
TEST(something) {
CHECK_EQUAL(static_cast<int>(Country::SPAIN), object.getCountry(1));
}