0

I have the following enum:

namespace Country {
    enum {
        ITALY = 1,
        SPAIN = 2
    };
}

And the following UnitTest++ test:

TEST(something) {
    CHECK_EQUAL(Country::SPAIN, object.getCountry(1)); // getCountry returns int
}

This doesn't work. I thought Country::SPAIN would be automatically converted to int 2, but instead I get this error:

error: no matching function for call to ‘CheckEqual(UnitTest::TestResults&, Country::<anonymous enum>, int, UnitTest::TestDetails)’
4

1 回答 1

1

将枚举投射给int自己:

TEST(something) {
    CHECK_EQUAL(static_cast<int>(Country::SPAIN), object.getCountry(1));
}
于 2011-03-29T23:51:24.790 回答