Setup new tests for extracting the EN pin logic
This commit is contained in:
parent
8e3978a089
commit
a09d7de1df
|
@ -54,3 +54,4 @@ add_subdirectory(RegEdit)
|
|||
add_subdirectory(usart)
|
||||
add_subdirectory(TriacOut)
|
||||
add_subdirectory(load)
|
||||
add_subdirectory(Enable)
|
||||
|
|
|
@ -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()
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -5,6 +5,7 @@
|
|||
IMPORT_TEST_GROUP(simple_test);
|
||||
IMPORT_TEST_GROUP(test_ADC);
|
||||
IMPORT_TEST_GROUP(test_RegEdit);
|
||||
IMPORT_TEST_GROUP(test_Enable);
|
||||
|
||||
|
||||
//START: main
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
project(Tests)
|
||||
|
||||
# TEST_DIRS
|
||||
add_subdirectory(Enable)
|
||||
#add_subdirectory(usart)
|
||||
add_subdirectory(MockADC)
|
||||
add_subdirectory(ADC)
|
||||
|
@ -20,6 +21,7 @@ target_link_libraries(AllTests
|
|||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||
# TEST_LINKS
|
||||
test_Enable
|
||||
test_ADC
|
||||
test_RegEdit
|
||||
simple_test
|
||||
|
|
|
@ -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
|
||||
)
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue