/*
 * Author: username
 * Date: todays_date
 * filename: test_MockRegEdit.c
 * description: module_purpose
 */

#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTest/UtestMacros.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, confirmgroup)
{
    CHECK_TRUE(true);
}

/*
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)
{
    uint32_t  a = 0xFFFFFFFF;
    uint32_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();
}
*/

TEST_GROUP(tg_mockregedit_u8){
    uint8_t fake_reg;
    uint8_t *reg_ptr;
    uint8_t num;
    void setup()
    {
        fake_reg = 0;
        reg_ptr = &fake_reg;
        num = 0;
    }
    void teardown()
    {
        mock().checkExpectations();
        mock().clear();   
    }
};

TEST(tg_mockregedit_u8, setregistercalled)
{
    mock().expectOneCall("RegEdit_u8_SetRegister").withPointerParameter("reg", reg_ptr);

    RegEdit_u8_SetRegister(reg_ptr);
}

TEST(tg_mockregedit_u8, clearregistercalled)
{
    mock().expectOneCall("RegEdit_u8_ClearRegister").withPointerParameter("reg", reg_ptr);
    
    RegEdit_u8_ClearRegister(reg_ptr);
}

TEST(tg_mockregedit_u8, setbitcalled)
{
    uint8_t num = 0;

    mock().expectOneCall("RegEdit_u8_SetBit")
        .withPointerParameter("reg", reg_ptr)
        .withUnsignedIntParameter("bit_num", num);

    RegEdit_u8_SetBit(reg_ptr, num);
}

TEST(tg_mockregedit_u8, clearbitcalled)
{
    mock().expectOneCall("RegEdit_u8_ClearBit")
        .withPointerParameter("reg", reg_ptr)
        .withUnsignedIntParameter("bit_num", num);
    
    RegEdit_u8_ClearBit(reg_ptr, num);
}

TEST(tg_mockregedit_u8, isbitsetcalled)
{
    mock().expectOneCall("RegEdit_u8_IsBitSet")
        .withPointerParameter("reg", reg_ptr)
        .withUnsignedIntParameter("bit_num", num);
    
    RegEdit_u8_IsBitSet(reg_ptr, num);
}

TEST(tg_mockregedit_u8, logicalornum)
{
    mock().expectOneCall("RegEdit_u8_OR_Num")
        .withPointerParameter("reg", reg_ptr)
        .withUnsignedIntParameter("num", num);
    
    RegEdit_u8_OR_Num(reg_ptr, num);
}

TEST(tg_mockregedit_u8, logicalandnum)
{
    mock().expectOneCall("RegEdit_u8_AND_Num")
        .withPointerParameter("reg", reg_ptr)
        .withUnsignedIntParameter("num", num);
    
    RegEdit_u8_AND_Num(reg_ptr, num);
}

TEST(tg_mockregedit_u8, setnumcalled)
{
    mock().expectOneCall("RegEdit_u8_SetNum")
        .withPointerParameter("reg", reg_ptr)
        .withUnsignedIntParameter("num", num);
    
    RegEdit_u8_SetNum(reg_ptr, num);
}

TEST(tg_mockregedit_u8, readregcalled)
{
    mock().expectOneCall("RegEdit_u8_ReadReg")
        .withPointerParameter("reg", reg_ptr);
 
    RegEdit_u8_ReadReg(reg_ptr);   
}

