updated with new function for the RegEdit mock
This commit is contained in:
parent
af3a041df8
commit
f536024959
|
@ -5,3 +5,8 @@ add_library(MockRegEdit STATIC
|
|||
target_include_directories(MockRegEdit PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(MockRegEdit
|
||||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||
)
|
||||
|
|
|
@ -71,3 +71,16 @@ void RegEdit_SetNum(void *reg, uint8_t num)
|
|||
->withPointerParameters("reg", reg)
|
||||
->withUnsignedIntParameters("num", num);
|
||||
}
|
||||
|
||||
|
||||
uint8_t RegEdit_ReadReg(void *reg)
|
||||
{
|
||||
uint8_t *reg_ptr = (uint8_t) reg;
|
||||
uint8_t reg_val = *reg_ptr;
|
||||
|
||||
mock_c()->actualCall("RegEdit_ReadReg")
|
||||
->withPointerParameters("reg", reg)
|
||||
->returnUnsignedIntValueOrDefault(reg_val);
|
||||
|
||||
return reg_val;
|
||||
}
|
||||
|
|
|
@ -25,4 +25,6 @@ void RegEdit_AND_Num(void *reg, uint8_t num);
|
|||
|
||||
void RegEdit_SetNum(void *reg, uint8_t num);
|
||||
|
||||
uint8_t RegEdit_ReadReg(void *reg);
|
||||
|
||||
#endif //MOCKREGEDIT_H
|
||||
|
|
|
@ -151,3 +151,18 @@ TEST(test_MockRegEdit, RegEdit_SetNumPasses)
|
|||
|
||||
mock().checkExpectations();
|
||||
}
|
||||
|
||||
TEST(test_MockRegEdit, RegEdit_ReadRegPasses)
|
||||
{
|
||||
uint8_t a = 0xFF;
|
||||
uint8_t *b = &a;
|
||||
|
||||
mock().expectOneCall("RegEdit_ReadReg")
|
||||
.withPointerParameter("reg", b)
|
||||
.andReturnValue(0xFF);
|
||||
uint8_t reg_val = RegEdit_ReadReg(b);
|
||||
|
||||
LONGS_EQUAL(0xFF, reg_val);
|
||||
|
||||
mock().checkExpectations();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue