Wrote tests for PortA Handler

This commit is contained in:
jakeg00dwin 2024-07-28 17:11:56 -07:00
parent 10867edb7a
commit 585cfd1ea0
1 changed files with 21 additions and 0 deletions

View File

@ -9,8 +9,13 @@
#include "CppUTestExt/MockSupport.h" #include "CppUTestExt/MockSupport.h"
#include <cstdint> #include <cstdint>
//This define allows us to dircetly include the device header without error.
#define _AVR_IO_H_
extern "C" extern "C"
{ {
#include <iotn404.h> //ATtiny404 header fille.
#include "load.h" #include "load.h"
#include "MockADC.h" #include "MockADC.h"
#include "MockADC.h" #include "MockADC.h"
@ -33,3 +38,19 @@ TEST(test_load, LoadPass)
{ {
CHECK_TRUE(true); 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);
}