Compare commits
7 commits
ae9a534c7f
...
a58ed1564e
| Author | SHA1 | Date | |
|---|---|---|---|
| a58ed1564e | |||
| bec64ac372 | |||
| 07fb8b48da | |||
| 8ef0f8307b | |||
| ea633bc0f4 | |||
| 32db51cb3c | |||
| 535dfee76e |
11 changed files with 106 additions and 369 deletions
|
|
@ -12,7 +12,7 @@ if(NOT UNIT_TESTING)
|
||||||
${CMAKE_SOURCE_DIR}/inc/
|
${CMAKE_SOURCE_DIR}/inc/
|
||||||
)
|
)
|
||||||
target_link_libraries(module_name
|
target_link_libraries(module_name
|
||||||
RegEdit
|
# RegEdit
|
||||||
)
|
)
|
||||||
|
|
||||||
#These get defined in the toolchain files.
|
#These get defined in the toolchain files.
|
||||||
|
|
@ -37,6 +37,6 @@ else()
|
||||||
)
|
)
|
||||||
#Place Mocked/Regular dependencies here for unit testing.
|
#Place Mocked/Regular dependencies here for unit testing.
|
||||||
target_link_libraries(module_name
|
target_link_libraries(module_name
|
||||||
MockRegEdit
|
# MockRegEdit
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module_name.h"
|
#include "module_name.h"
|
||||||
#include "RegEdit.h"
|
|
||||||
|
|
||||||
// dumb test function
|
// dumb test function
|
||||||
int add_two(int a)
|
int add_two(int a)
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,14 @@ TEST_GROUP(tg_module_name)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(tg_module_name, FirstTest)
|
TEST(tg_module_name, groupRuns)
|
||||||
{
|
{
|
||||||
FAIL("Fail me!");
|
CHECK_TRUE(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(tg_module_name, SecondTest)
|
TEST(tg_module_name, TemplateFunctionWorks)
|
||||||
{
|
{
|
||||||
STRCMP_EQUAL("hello", "world");
|
int a = 2;
|
||||||
LONGS_EQUAL(1, 2);
|
int b = add_two(a);
|
||||||
CHECK(false);
|
CHECK_EQUAL_TEXT(4, b, "Returned value incorrect!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
12
Doxyfile
12
Doxyfile
|
|
@ -42,13 +42,13 @@ DOXYFILE_ENCODING = UTF-8
|
||||||
# title of most generated pages and in a few other places.
|
# title of most generated pages and in a few other places.
|
||||||
# The default value is: My Project.
|
# The default value is: My Project.
|
||||||
|
|
||||||
PROJECT_NAME = "My Project"
|
PROJECT_NAME = "project_name"
|
||||||
|
|
||||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER =
|
PROJECT_NUMBER = 0.1.0
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
|
|
@ -502,7 +502,7 @@ LOOKUP_CACHE_SIZE = 0
|
||||||
# DOT_NUM_THREADS setting.
|
# DOT_NUM_THREADS setting.
|
||||||
# Minimum value: 0, maximum value: 32, default value: 1.
|
# Minimum value: 0, maximum value: 32, default value: 1.
|
||||||
|
|
||||||
NUM_PROC_THREADS = 1
|
NUM_PROC_THREADS = 32
|
||||||
|
|
||||||
# If the TIMESTAMP tag is set different from NO then each generated page will
|
# If the TIMESTAMP tag is set different from NO then each generated page will
|
||||||
# contain the date or date and time when the page was generated. Setting this to
|
# contain the date or date and time when the page was generated. Setting this to
|
||||||
|
|
@ -2502,7 +2502,7 @@ HIDE_UNDOC_RELATIONS = YES
|
||||||
# set to NO
|
# set to NO
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
HAVE_DOT = NO
|
HAVE_DOT = YES
|
||||||
|
|
||||||
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
|
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
|
||||||
# to run in parallel. When set to 0 doxygen will base this on the number of
|
# to run in parallel. When set to 0 doxygen will base this on the number of
|
||||||
|
|
@ -2512,7 +2512,7 @@ HAVE_DOT = NO
|
||||||
# Minimum value: 0, maximum value: 32, default value: 0.
|
# Minimum value: 0, maximum value: 32, default value: 0.
|
||||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||||
|
|
||||||
DOT_NUM_THREADS = 0
|
DOT_NUM_THREADS = 32
|
||||||
|
|
||||||
# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of
|
# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of
|
||||||
# subgraphs. When you want a differently looking font in the dot files that
|
# subgraphs. When you want a differently looking font in the dot files that
|
||||||
|
|
@ -2674,7 +2674,7 @@ INCLUDED_BY_GRAPH = YES
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||||
|
|
||||||
CALL_GRAPH = NO
|
CALL_GRAPH = YES
|
||||||
|
|
||||||
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
|
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
|
||||||
# dependency graph for every global function or class method.
|
# dependency graph for every global function or class method.
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,26 @@ TEMPLATE_FILES=".template_files"
|
||||||
MODULE_DIR="${TEMPLATE_FILES}/modules"
|
MODULE_DIR="${TEMPLATE_FILES}/modules"
|
||||||
TEST_MODULE_DIR="${TEMPLATE_FILES}/test_module"
|
TEST_MODULE_DIR="${TEMPLATE_FILES}/test_module"
|
||||||
|
|
||||||
|
IS_FREEBSD=0
|
||||||
|
IS_LINUX=0
|
||||||
|
|
||||||
PROJECT_NAME="template"
|
PROJECT_NAME="template"
|
||||||
|
|
||||||
|
check_os() {
|
||||||
|
if [[ "${OSTYPE}" == *"freebsd"* ]]; then
|
||||||
|
IS_FREEBSD=1
|
||||||
|
IS_LINUX=0
|
||||||
|
elif [[ "${OSTYPE}" == *"linux"* ]]; then
|
||||||
|
IS_FREEBSD=0
|
||||||
|
IS_LINUX=1
|
||||||
|
else
|
||||||
|
echo "Error, unknown OS type!"
|
||||||
|
IS_FREEBSD=0
|
||||||
|
IS_LINUX=0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
run_uc_tags() {
|
run_uc_tags() {
|
||||||
uctags --recurse=yes \
|
uctags --recurse=yes \
|
||||||
--languages=C,C++,Asm \
|
--languages=C,C++,Asm \
|
||||||
|
|
@ -115,19 +133,32 @@ add_module_to_cmakes () {
|
||||||
echo "add_subdirectory(${basename})" >> ./src/CMakeLists.txt
|
echo "add_subdirectory(${basename})" >> ./src/CMakeLists.txt
|
||||||
|
|
||||||
# Tests cmake file needs to be edited in place.
|
# Tests cmake file needs to be edited in place.
|
||||||
# sed -i'' "s/# TEST_DIRS.*$/# TEST_DIRS\r\nadd_subdirectory(${basename})/g" ./tests/CMakeLists.txt
|
if [ $IS_FREEBSD -eq 1 ]; then
|
||||||
# sed -i'' "s/# TEST_LINKS.*$/# TEST_LINKS\r\n\t${basename}/g" ./tests/CMakeLists.txt
|
|
||||||
sed -i '' -e "s|# TEST_DIRS.*$|# TEST_DIRS\nadd_subdirectory(${basename})|" ./tests/CMakeLists.txt
|
sed -i '' -e "s|# TEST_DIRS.*$|# TEST_DIRS\nadd_subdirectory(${basename})|" ./tests/CMakeLists.txt
|
||||||
sed -i '' -e "s|# TEST_LINKS.*$|# TEST_LINKS\ntest_${basename}|" ./tests/CMakeLists.txt
|
sed -i '' -e "s|# TEST_LINKS.*$|# TEST_LINKS\n\ttest_${basename}|" ./tests/CMakeLists.txt
|
||||||
|
elif [ $IS_LINUX -eq 1 ]; then
|
||||||
|
sed -i -e "s|# TEST_DIRS.*$|# TEST_DIRS\nadd_subdirectory(${basename})|" ./tests/CMakeLists.txt
|
||||||
|
sed -i -e "s|# TEST_LINKS.*$|# TEST_LINKS\n\ttest_${basename}|" ./tests/CMakeLists.txt
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_module_from_cmakes () {
|
remove_module_from_cmakes () {
|
||||||
local basename="$1"
|
local basename="$1"
|
||||||
|
|
||||||
sed -i'' "s/^.*add_subdirectory(${basename}).*$//g" ./src/CMakeLists.txt
|
|
||||||
sed -i'' "s/^.*add_subdirectory(${basename}).*$//g" ./tests/CMakeLists.txt
|
if [ $IS_FREEBSD -eq 1 ]; then
|
||||||
sed -i'' "s/^.*${basename}.*$//g" ./tests/CMakeLists.txt
|
sed -i '' "s/^.*add_subdirectory(${basename}).*$//g" ./src/CMakeLists.txt
|
||||||
# sed -i'' "s/^.*test_${basename}.*$//g" ./tests/CMakeLists.txt
|
sed -i '' "s/^.*add_subdirectory(${basename}).*$//g" ./tests/CMakeLists.txt
|
||||||
|
sed -i '' "s/^.*${basename}.*$//g" ./tests/CMakeLists.txt
|
||||||
|
sed -i '' "s/^.*${basename}.*$//g" ./tests/AllTests.cpp
|
||||||
|
elif [ $IS_LINUX -eq 1 ]; then
|
||||||
|
sed -i "s/^.*add_subdirectory(${basename}).*$//g" ./src/CMakeLists.txt
|
||||||
|
sed -i "s/^.*add_subdirectory(${basename}).*$//g" ./tests/CMakeLists.txt
|
||||||
|
sed -i "s/^.*${basename}.*$//g" ./tests/CMakeLists.txt
|
||||||
|
sed -i "s/^.*${basename}.*$//g" ./tests/AllTests.cpp
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
git_add_module () {
|
git_add_module () {
|
||||||
|
|
@ -190,7 +221,7 @@ add_new_module () {
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g')
|
modname_cap=$( printf '%s' "$modname" | tr '[:lower:]' '[:upper:]' )
|
||||||
modsrc_dir="./src/${modname}"
|
modsrc_dir="./src/${modname}"
|
||||||
modtest_dir="./tests/${modname}"
|
modtest_dir="./tests/${modname}"
|
||||||
|
|
||||||
|
|
@ -211,7 +242,7 @@ add_new_module () {
|
||||||
case $lanuage_selection in
|
case $lanuage_selection in
|
||||||
1)
|
1)
|
||||||
echo "You selected Option 1"
|
echo "You selected Option 1"
|
||||||
add_c_mdoule
|
add_c_module
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
echo "You selected Option 2"
|
echo "You selected Option 2"
|
||||||
|
|
@ -228,19 +259,42 @@ add_new_module () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_c_mdoule () {
|
add_c_module () {
|
||||||
|
|
||||||
|
if [ $IS_FREEBSD -eq 1 ]; then
|
||||||
sed -e "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
|
||||||
sed -i'' -e "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
|
sed -i '' -e "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
|
||||||
|
|
||||||
sed -e "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
|
sed -e "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
|
||||||
sed -i'' -e "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
|
sed -i '' -e "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
|
||||||
|
|
||||||
sed -e "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
|
||||||
|
|
||||||
sed -e "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
|
||||||
sed -e "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
||||||
|
|
||||||
|
#Add module to Alltests.
|
||||||
|
sed -i '' -e "s/\/\/ImportTestGroups/\/\/ImportTestGroups\nIMPORT_TEST_GROUP(tg_${modname});/" ./tests/AllTests.cpp
|
||||||
|
|
||||||
|
elif [ $IS_LINUX -eq 1 ]; then
|
||||||
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
|
||||||
|
sed -i '' -e "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
|
||||||
|
|
||||||
|
sed -e "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
|
||||||
|
sed -i '' -e "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
|
||||||
|
|
||||||
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
|
||||||
|
|
||||||
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
|
||||||
|
sed -e "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
||||||
|
|
||||||
|
#Add module to Alltests.
|
||||||
|
sed -i '' -e "s/\/\/ImportTestGroups/\/\/ImportTestGroups\nIMPORT_TEST_GROUP(tg_${modname});/" ./tests/AllTests.cpp
|
||||||
|
else
|
||||||
|
printf "Error unknown OS!\r\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
# Add the module to the cmake lists files.
|
# Add the module to the cmake lists files.
|
||||||
add_module_to_cmakes "${modname}"
|
add_module_to_cmakes "${modname}"
|
||||||
|
|
||||||
|
|
@ -252,6 +306,7 @@ add_c_mdoule () {
|
||||||
|
|
||||||
add_cpp_module () {
|
add_cpp_module () {
|
||||||
|
|
||||||
|
if [ $IS_FREEBSD -eq 1 ]; then
|
||||||
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.cpp > $modsrc_dir/${modname}.cpp
|
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.cpp > $modsrc_dir/${modname}.cpp
|
||||||
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.cpp
|
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.cpp
|
||||||
|
|
||||||
|
|
@ -263,6 +318,13 @@ add_cpp_module () {
|
||||||
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
|
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
|
||||||
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
||||||
|
|
||||||
|
elif [ $IS_LINUX -eq 1 ]; then
|
||||||
|
echo "Not yet implimented"
|
||||||
|
else
|
||||||
|
printf "Error unknown OS!\r\n"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
# Add the module to the cmake lists files.
|
# Add the module to the cmake lists files.
|
||||||
add_module_to_cmakes "${modname}"
|
add_module_to_cmakes "${modname}"
|
||||||
|
|
||||||
|
|
@ -342,6 +404,7 @@ print_menu () {
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
check_os
|
||||||
add_compile_commands
|
add_compile_commands
|
||||||
valid_choice=false
|
valid_choice=false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
add_subdirectory(MockRegEdit)
|
|
||||||
add_subdirectory(MockADC)
|
add_subdirectory(MockADC)
|
||||||
add_subdirectory(TimerMock)
|
add_subdirectory(TimerMock)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
add_library(MockRegEdit STATIC
|
|
||||||
MockRegEdit.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(MockRegEdit PUBLIC
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
${CMAKE_SOURCE_DIR}/src/RegEdit/
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(MockRegEdit
|
|
||||||
${CPPUTEST_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
/*
|
|
||||||
* Author: username
|
|
||||||
* Date: 2024
|
|
||||||
* filename: MockRegEdit.c
|
|
||||||
* description: module_purpose
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "MockRegEdit.h"
|
|
||||||
#include "CppUTestExt/MockSupport_c.h"
|
|
||||||
|
|
||||||
// For 64-Bit systems and register access.
|
|
||||||
|
|
||||||
void RegEdit_u64_SetRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_SetRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u64_ClearRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_ClearRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u64_SetBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_SetBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u64_ClearBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_ClearBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegEdit_u64_IsBitSet(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
return mock_c()->actualCall("RegEdit_u64_IsBitSet")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num)->returnBoolValueOrDefault(true);
|
|
||||||
// return mock_c()->returnBoolValueOrDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u64_OR_Num(void *reg, uint64_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_OR_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u64_AND_Num(void *reg, uint64_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_AND_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u64_SetNum(void *reg, uint64_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u64_SetNum")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t RegEdit_u64_ReadReg(void *reg)
|
|
||||||
{
|
|
||||||
uint64_t value = *(uint64_t *)reg;
|
|
||||||
|
|
||||||
mock_c()->actualCall("RegEdit_u64_ReadReg")->withPointerParameters("reg", reg)->returnUnsignedIntValueOrDefault(value);
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For 32-Bit systems and register access.
|
|
||||||
|
|
||||||
void RegEdit_u32_SetRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_SetRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u32_ClearRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_ClearRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u32_SetBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_SetBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u32_ClearBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_ClearBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegEdit_u32_IsBitSet(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
return mock_c()->actualCall("RegEdit_u32_IsBitSet")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num)->returnBoolValueOrDefault(true);
|
|
||||||
// return mock_c()->returnBoolValueOrDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u32_OR_Num(void *reg, uint32_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_OR_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u32_AND_Num(void *reg, uint32_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_AND_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u32_SetNum(void *reg, uint32_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u32_SetNum")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t RegEdit_u32_ReadReg(void *reg)
|
|
||||||
{
|
|
||||||
uint32_t value = *(uint32_t *)reg;
|
|
||||||
|
|
||||||
mock_c()->actualCall("RegEdit_u32_ReadReg")->withPointerParameters("reg", reg)->returnUnsignedIntValueOrDefault(value);
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For 16-Bit systems and register access.
|
|
||||||
|
|
||||||
void RegEdit_u16_SetRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_SetRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u16_ClearRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_ClearRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u16_SetBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_SetBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u16_ClearBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_ClearBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegEdit_u16_IsBitSet(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
return mock_c()->actualCall("RegEdit_u16_IsBitSet")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num)->returnBoolValueOrDefault(true);
|
|
||||||
// return mock_c()->returnBoolValueOrDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u16_OR_Num(void *reg, uint16_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_OR_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u16_AND_Num(void *reg, uint16_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_AND_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u16_SetNum(void *reg, uint16_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u16_SetNum")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t RegEdit_u16_ReadReg(void *reg)
|
|
||||||
{
|
|
||||||
uint16_t value = *(uint16_t *)reg;
|
|
||||||
|
|
||||||
mock_c()->actualCall("RegEdit_u16_ReadReg")->withPointerParameters("reg", reg)->returnUnsignedIntValueOrDefault(value);
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For 8-Bit systems and register access.
|
|
||||||
|
|
||||||
void RegEdit_u8_SetRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_SetRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u8_ClearRegister(void *reg)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_ClearRegister")->withPointerParameters("reg", reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u8_SetBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_SetBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u8_ClearBit(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_ClearBit")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RegEdit_u8_IsBitSet(void *reg, uint8_t bit_num)
|
|
||||||
{
|
|
||||||
return mock_c()->actualCall("RegEdit_u8_IsBitSet")->withPointerParameters("reg", reg)->withUnsignedIntParameters("bit_num", bit_num)->returnBoolValueOrDefault(true);
|
|
||||||
// return mock_c()->returnBoolValueOrDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u8_OR_Num(void *reg, uint8_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_OR_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u8_AND_Num(void *reg, uint8_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_AND_Num")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegEdit_u8_SetNum(void *reg, uint8_t num)
|
|
||||||
{
|
|
||||||
mock_c()->actualCall("RegEdit_u8_SetNum")->withPointerParameters("reg", reg)->withUnsignedIntParameters("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RegEdit_u8_ReadReg(void *reg)
|
|
||||||
{
|
|
||||||
uint8_t value = *(uint8_t *)reg;
|
|
||||||
|
|
||||||
mock_c()->actualCall("RegEdit_u8_ReadReg")->withPointerParameters("reg", reg)->returnUnsignedIntValueOrDefault(value);
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
/**
|
|
||||||
* @brief Mock of the RegEdit module.
|
|
||||||
* @details This file is just re-exports the RegEdit functions plus extras.
|
|
||||||
* @author Jake G
|
|
||||||
* @date 2025-12-21
|
|
||||||
* @copyright None
|
|
||||||
* @file MockRegEdit.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MOCKREGEDIT_H
|
|
||||||
#define MOCKREGEDIT_H
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "RegEdit.h"
|
|
||||||
|
|
||||||
#endif // MOCKREGEDIT_H
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
#include "u8_comparator.hpp"
|
|
||||||
#include "CppUTest/SimpleString.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
class MyTypeComparator : public MockNamedValueComparator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual bool isEqual(const void* object1, const void* object2)
|
|
||||||
{
|
|
||||||
return object1 == object2;
|
|
||||||
}
|
|
||||||
virtual SimpleString valueToString(const void* object)
|
|
||||||
{
|
|
||||||
return StringFrom(object);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool UInt8PointerComparator::isEqual(const void *object1, const void *object2)
|
|
||||||
{
|
|
||||||
const uint8_t *ptr1 = reinterpret_cast<const uint8_t *>(object1);
|
|
||||||
const uint8_t *ptr2 = reinterpret_cast<const uint8_t *>(object2);
|
|
||||||
return std::memcmp(ptr1, ptr2, sizeof(uint8_t)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleString UInt8PointerComparator::valueToString(const void *object)
|
|
||||||
{
|
|
||||||
const uint8_t *ptr = reinterpret_cast<const uint8_t *>(object);
|
|
||||||
return StringFromFormat("0x%02x", *ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
bool UInt8PointerComparator::isEqual(const void* object1, const void* object2) const {
|
|
||||||
const uint8_t* ptr1 = static_cast<const uint8_t*>(object1);
|
|
||||||
const uint8_t* ptr2 = static_cast<const uint8_t*>(object2);
|
|
||||||
return std::memcmp(ptr1, ptr2, sizeof(uint8_t)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleString UInt8PointerComparator::valueToString(const void* object) const {
|
|
||||||
const uint8_t* ptr = static_cast<const uint8_t*>(object);
|
|
||||||
return StringFromFormat("0x%02x", *ptr);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool UInt8Comparator::isEqual(const void *object1, const void *object2)
|
|
||||||
{
|
|
||||||
return (uint8_t *)object1 == (uint8_t *)object2;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleString UInt8Comparator::valueToString(const void *object)
|
|
||||||
{
|
|
||||||
// uint8_t value = reinterpret_cast<uint8_t>(object);
|
|
||||||
const uint8_t *ptr = reinterpret_cast<const uint8_t *>(object);
|
|
||||||
return StringFromFormat("0x%02x", *ptr);
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
#ifndef U8_COMPARATOR_H
|
|
||||||
#define U8_COMPARATOR_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
#include <CppUTestExt/MockSupport.h>
|
|
||||||
|
|
||||||
class UInt8PointerComparator : public MockNamedValueComparator {
|
|
||||||
public:
|
|
||||||
virtual bool isEqual(const void* object1, const void* object2) override;
|
|
||||||
SimpleString valueToString(const void* object) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class UInt8Comparator : public MockNamedValueComparator {
|
|
||||||
public:
|
|
||||||
virtual bool isEqual(const void* object1, const void* object2) override;
|
|
||||||
SimpleString valueToString(const void* object) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //U8_COMPARATOR_H
|
|
||||||
Loading…
Add table
Reference in a new issue