fg004_a1/tests/MockRegEdit/test_MockRegEdit.cpp

169 lines
3.1 KiB
C++
Raw Normal View History

/*
* Author: username
* Date: todays_date
* filename: test_MockRegEdit.c
* description: module_purpose
*/
#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTestExt/MockSupport.h"
#include <cstdint>
extern "C"
{
#include "MockRegEdit.h"
}
TEST_GROUP(test_MockRegEdit)
{
void setup()
{
}
void teardown()
{
mock().clear();
}
};
TEST(test_MockRegEdit, RegEdit_ClearRegisterExpectedCallPasses)
{
uint8_t a;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_ClearRegister")
.withPointerParameter("reg", b);
RegEdit_ClearRegister(b);
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_SetRegisterExpectedCallPasses)
{
uint8_t a;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_SetRegister")
.withPointerParameter("reg", b);
RegEdit_SetRegister(b);
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_SetBitExpectedCallPasses)
{
uint8_t a;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", b)
.withUnsignedIntParameter("bit_num", 5);
RegEdit_SetBit(b, 5);
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_ClearBitExpectedCallPasses)
{
uint8_t a;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", b)
.withUnsignedIntParameter("bit_num", 5);
RegEdit_ClearBit(b, 5);
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_IsBitSetExpectedCallPasses)
{
uint8_t a = 0xFF;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_IsBitSet")
.withPointerParameter("reg", b)
.withUnsignedIntParameter("bit_num", 5)
.andReturnValue(true);
CHECK_TRUE(RegEdit_IsBitSet(b, 5));
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_IsBitSetExpectedCallPassesWithFalse)
{
uint8_t a = 0xFF;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_IsBitSet")
.withPointerParameter("reg", b)
.withUnsignedIntParameter("bit_num", 5)
.andReturnValue(false);
CHECK_FALSE(RegEdit_IsBitSet(b, 5));
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_OR_NumExpectedWorks)
{
uint8_t a = 0xFF;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_OR_Num")
.withPointerParameter("reg", b)
.withUnsignedIntParameter("num", 0x4)
.andReturnValue(false);
RegEdit_OR_Num(b, 0x4);
mock().checkExpectations();
}
TEST(test_MockRegEdit, RegEdit_SetNumPasses)
{
uint8_t a = 0xFF;
uint8_t *b = &a;
mock().expectOneCall("RegEdit_SetNum")
.withPointerParameter("reg", b)
.withUnsignedIntParameter("num", 0x4)
.andReturnValue(false);
RegEdit_SetNum(b, 0x4);
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();
}