Patched from High Repo
This commit is contained in:
parent
0eb4acc3f5
commit
a118d621c8
|
@ -13,16 +13,30 @@
|
|||
uint16_t fake_data[FAKESIZE];
|
||||
int fake_index = 0;
|
||||
|
||||
static bool is_setup = false;
|
||||
|
||||
|
||||
|
||||
void ADC_SetPin(uint8_t pin_num)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void ADC_Setup(void)
|
||||
{
|
||||
is_setup = true;
|
||||
return;
|
||||
}
|
||||
|
||||
void ADC_Init(uint8_t pin_num)
|
||||
{
|
||||
mock_c()->actualCall("ADC_Init")
|
||||
->withUnsignedIntParameters("pin_num", pin_num);
|
||||
}
|
||||
|
||||
void ADC_Enable(uint8_t pin_num)
|
||||
void ADC_Enable(void)
|
||||
{
|
||||
mock_c()->actualCall("ADC_Enable")
|
||||
->withUnsignedIntParameters("pin_num", pin_num);
|
||||
mock_c()->actualCall("ADC_Enable");
|
||||
}
|
||||
|
||||
void ADC_Disable()
|
||||
|
@ -62,3 +76,9 @@ int MockADC_GetIndex(void)
|
|||
{
|
||||
return fake_index;
|
||||
}
|
||||
|
||||
|
||||
bool MockADC_IsSetup(void)
|
||||
{
|
||||
return is_setup;
|
||||
}
|
||||
|
|
|
@ -13,18 +13,18 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* A function that adds two to a number
|
||||
* @param a The first argument
|
||||
*/
|
||||
|
||||
void ADC_Setup(void);
|
||||
void ADC_SetPin(uint8_t pin_num);
|
||||
void ADC_Init(uint8_t pin_num);
|
||||
void ADC_Enable(uint8_t pin_num);
|
||||
void ADC_Disable();
|
||||
void ADC_Enable(void);
|
||||
void ADC_Disable(void);
|
||||
|
||||
extern uint16_t (*ADC_ReadValue)(uint8_t pin_num);
|
||||
|
||||
void MockADC_PushValue(uint16_t value);
|
||||
void MockADC_ZeroIndex(void);
|
||||
int MockADC_GetIndex(void);
|
||||
bool MockADC_IsSetup(void);
|
||||
|
||||
#endif //MOCKADC_H
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
|
||||
void ZCD_Setup(void)
|
||||
{
|
||||
ADC_Init(7);
|
||||
ADC_Enable(7);
|
||||
ADC_Init(ZCD_PIN);
|
||||
ADC_SetPin(ZCD_PIN);
|
||||
ADC_Enable();
|
||||
}
|
||||
|
||||
bool ZCD_IsTriggered()
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# TEST_RUNNER
|
||||
add_library(test_load
|
||||
test_load.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(test_load
|
||||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||
load
|
||||
MockADC
|
||||
MockRegEdit
|
||||
)
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Author: Jake G
|
||||
* Date: 2024
|
||||
* filename: test_load.cpp
|
||||
* description:
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTestExt/MockSupport.h"
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
//This define allows us to dircetly include the device header without error.
|
||||
#define _AVR_IO_H_
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <iotn404.h> //ATtiny404 header fille.
|
||||
#include "load.h"
|
||||
#include "MockADC.h"
|
||||
#include "MockADC.h"
|
||||
}
|
||||
|
||||
TEST_GROUP(test_load)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
mock().checkExpectations();
|
||||
mock().clear();
|
||||
}
|
||||
};
|
||||
|
||||
TEST(test_load, LoadPass)
|
||||
{
|
||||
CHECK_TRUE(true);
|
||||
}
|
||||
|
||||
TEST(test_load, PortAHandlerSuccess)
|
||||
{
|
||||
mock().expectOneCall("ADC_Init")
|
||||
.withUnsignedIntParameter("pin_num", 4);
|
||||
|
||||
mock().expectOneCall("ADC_Enable");
|
||||
mock().expectOneCall("ADC_ReadValue_Impl")
|
||||
.withUnsignedIntParameter("pin_num", 4);
|
||||
mock().expectOneCall("ADC_Disable");
|
||||
mock().expectOneCall("RegEdit_ClearBit")
|
||||
.withPointerParameter("reg", (void *) &PORTA.OUT)
|
||||
.withUnsignedIntParameter("bit_num", 7);
|
||||
|
||||
Load_HandleLoadPortA(4, 7);
|
||||
}
|
Loading…
Reference in New Issue