Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Jake Goodwin 2025-07-01 20:23:43 -07:00
commit 5a1692b8df
4 changed files with 74 additions and 11 deletions

View file

@ -0,0 +1,16 @@
/*
* Author: username
* Date: todays_date
* filename: module_name.cpp
* description: module_purpose
*/
#include "module_name.h"
// dumb test function
int add_two(int a)
{
int b = a;
b += 2;
return b;
}

View file

@ -12,7 +12,7 @@ extern "C"
#include "module_name.h"
}
TEST_GROUP(FirstTestGroup)
TEST_GROUP(test_module_name)
{
void setup()
{
@ -24,12 +24,12 @@ TEST_GROUP(FirstTestGroup)
}
};
TEST(FirstTestGroup, FirstTest)
TEST(test_module_name, FirstTest)
{
FAIL("Fail me!");
}
TEST(FirstTestGroup, SecondTest)
TEST(test_module_name, SecondTest)
{
STRCMP_EQUAL("hello", "world");
LONGS_EQUAL(1, 2);

View file

@ -39,7 +39,9 @@ set(CMAKE_CXX_FLAGS "-Wall -Werror -Wpedantic")
if (UNIT_TESTING)
#Allows usage of preprossor stuff in your files.
add_compile_definitions(UNIT_TESTING=1)
if(DEFINED ENV{CPPUTEST_HOME})
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
@ -53,7 +55,6 @@ if (UNIT_TESTING)
include_directories(
${CPPUTEST_INCLUDE_DIRS}
/usr/include/c++/11/
./inc
./mocks
)

58
otto.sh
View file

@ -126,6 +126,7 @@ git_remove_module () {
add_new_module () {
read -p "Enter the name of the module:" modname
result=$(does_module_exist "$modname")
@ -152,7 +153,35 @@ add_new_module () {
#copy the template files.
echo "copying & customizing template files..."
echo "Select an option:"
echo "1.) Add a C module"
echo "2.) Add a C++ module"
read -P "choice:" lanuage_selection
case $lanuage_selection in
1)
echo "You selected Option 1"
add_c_mdoule
;;
2)
echo "You selected Option 2"
add_cpp_module
;;
*)
echo "Invalid Choice!\nExiting..."
;;
esac
# Now we add the new files to the git tracked files
git_add_module "${modname}"
}
add_c_mdoule () {
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
@ -170,13 +199,30 @@ add_new_module () {
echo "Resulting files/dirs:"
tree -L 2 $modsrc_dir
tree -L 2 $modtest_dir
# Now we add the new files to the git tracked files
git_add_module "${modname}"
}
add_cpp_module () {
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 "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
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
# Add the module to the cmake lists files.
add_module_to_cmakes "${modname}"
echo "Resulting files/dirs:"
tree -L 2 $modsrc_dir
tree -L 2 $modtest_dir
}
del_module () {
read -p "Enter the name of the module:" modname
@ -207,7 +253,7 @@ run_c_tests () {
format_source_code
clear_cmake_cache
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
make AllTests && ./tests/AllTests
make AllTests && ./tests/AllTests -v -c
}
print_menu () {