When I try and reference an enum class
from a test fixture, it fails to compile with error ./gtest_mcp23s17.cpp:25:52: error: no type named 'HW_ADDR_6' in 'mcp23s17::HardwareAddress'
TC_mcp23s17 _gpio_x(mcp23s17::HardwareAddress::HW_ADDR_6);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
However, if I leave the reference in the test itself (leaving ALL other code untouched), it compiles without error and runs the test as you would expect. Is this a bug in GoogleTest, or what differentiates this scenario as far as the test is concerned?
Test (generic): [COMPILES]
TEST(Construction, WHENObjectIsConstructedTHENAddressParameterIsStored) {
TC_mcp23s17 gpio_x(mcp23s17::HardwareAddress::HW_ADDR_6);
EXPECT_EQ(0x4C, gpio_x.getSpiBusAddress());
}
Test Fixture: [COMPILES]
TEST_F(SPITransfer, WHENPinModeHasNotBeenCalledTHENTheCallersChipSelectPinIsHigh) {
TC_mcp23s17 gpio_x(mcp23s17::HardwareAddress::HW_ADDR_6);
EXPECT_EQ(HIGH, getPinLatchValue(SS));
}
Test Fixture (with gpio_x declared in fixture class): [FAILS]
class SPITransfer : public ::testing::Test {
protected:
TC_mcp23s17 gpio_x(mcp23s17::HardwareAddress::HW_ADDR_6);
...
}
TEST_F(SPITransfer, WHENPinModeHasNotBeenCalledTHENTheCallersChipSelectPinIsHigh) {
EXPECT_EQ(HIGH, getPinLatchValue(SS));
}