updated with new function for the RegEdit mock

This commit is contained in:
jakeg00dwin 2024-07-26 18:16:09 -07:00
parent af3a041df8
commit f536024959
4 changed files with 35 additions and 0 deletions

View File

@ -5,3 +5,8 @@ add_library(MockRegEdit STATIC
target_include_directories(MockRegEdit PUBLIC target_include_directories(MockRegEdit PUBLIC
${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}
) )
target_link_libraries(MockRegEdit
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
)

View File

@ -71,3 +71,16 @@ void RegEdit_SetNum(void *reg, uint8_t num)
->withPointerParameters("reg", reg) ->withPointerParameters("reg", reg)
->withUnsignedIntParameters("num", num); ->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;
}

View File

@ -25,4 +25,6 @@ void RegEdit_AND_Num(void *reg, uint8_t num);
void RegEdit_SetNum(void *reg, uint8_t num); void RegEdit_SetNum(void *reg, uint8_t num);
uint8_t RegEdit_ReadReg(void *reg);
#endif //MOCKREGEDIT_H #endif //MOCKREGEDIT_H

View File

@ -151,3 +151,18 @@ TEST(test_MockRegEdit, RegEdit_SetNumPasses)
mock().checkExpectations(); 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();
}