Setup new tests for extracting the EN pin logic

This commit is contained in:
jakeg00dwin 2024-07-27 12:48:34 -07:00
parent 8e3978a089
commit a09d7de1df
8 changed files with 121 additions and 0 deletions

View File

@ -54,3 +54,4 @@ add_subdirectory(RegEdit)
add_subdirectory(usart) add_subdirectory(usart)
add_subdirectory(TriacOut) add_subdirectory(TriacOut)
add_subdirectory(load) add_subdirectory(load)
add_subdirectory(Enable)

17
src/Enable/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
add_library(Enable STATIC
Enable.c
)
target_include_directories(Enable PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
if(UNIT_TESTING)
target_link_libraries(Enable
MockRegEdit
)
else()
target_link_libraries(Enable
RegEdit
)
endif()

21
src/Enable/Enable.c Normal file
View File

@ -0,0 +1,21 @@
/*
* Author: username
* Date: 2024
* filename: Enable.c
* description: module_purpose
*/
#ifndef __AVR_ATtiny404__
#define __AVR_ATtiny404__
#endif
#include "Enable.h"
#include "avr/io.h"
#include "RegEdit.h"
void Enable_SetPinsHigh()
{
RegEdit_SetBit((void *) &PORTA.DIR, EN1);
return;
}

24
src/Enable/Enable.h Normal file
View File

@ -0,0 +1,24 @@
/**
* @brief PUT_TEXT_HERE
* @details This file is...
* @author username
* @date todays_date
* @copyright None
* @file ENABLE.h
*/
#ifndef ENABLE
#define ENABLE
#define EN1 (1<<2)
#define EN2 (1<<3)
#define EN3 (1<<2)
/**
* Sets all the Enable pins high.
*/
void Enable_SetPinsHigh();
#endif //ENABLE

View File

@ -5,6 +5,7 @@
IMPORT_TEST_GROUP(simple_test); IMPORT_TEST_GROUP(simple_test);
IMPORT_TEST_GROUP(test_ADC); IMPORT_TEST_GROUP(test_ADC);
IMPORT_TEST_GROUP(test_RegEdit); IMPORT_TEST_GROUP(test_RegEdit);
IMPORT_TEST_GROUP(test_Enable);
//START: main //START: main

View File

@ -1,6 +1,7 @@
project(Tests) project(Tests)
# TEST_DIRS # TEST_DIRS
add_subdirectory(Enable)
#add_subdirectory(usart) #add_subdirectory(usart)
add_subdirectory(MockADC) add_subdirectory(MockADC)
add_subdirectory(ADC) add_subdirectory(ADC)
@ -20,6 +21,7 @@ target_link_libraries(AllTests
${CPPUTEST_LIBRARIES}/libCppUTest.a ${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a ${CPPUTEST_LIBRARIES}/libCppUTestExt.a
# TEST_LINKS # TEST_LINKS
test_Enable
test_ADC test_ADC
test_RegEdit test_RegEdit
simple_test simple_test

View File

@ -0,0 +1,11 @@
# TEST_RUNNER
add_library(test_Enable
test_Enable.cpp
)
target_link_libraries(test_Enable
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
MockRegEdit
Enable
)

View File

@ -0,0 +1,44 @@
/*
* Author: username
* Date: todays_date
* filename: test_Enable.c
* description: module_purpose
*/
#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTestExt/MockSupport.h"
//This define allows us to dircetly include the device header without error.
#define _AVR_IO_H_
extern "C"
{
#include <iotn404.h>
#include "Enable.h"
#include "MockRegEdit.h"
}
TEST_GROUP(test_Enable)
{
void setup()
{
}
void teardown()
{
mock().checkExpectations();
mock().clear();
}
};
TEST(test_Enable, SetEnablePinsHighCallsCorrectFuncs)
{
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.DIR)
.withUnsignedIntParameter("bit_num", EN1);
Enable_SetPinsHigh();
}