From 2567e752fc0906097cf2767709c4ebcf3fbd66ce Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Sun, 1 Sep 2024 09:31:02 -0700 Subject: [PATCH] Updated source and test code to run the SuperLoop tests --- src/CMakeLists.txt | 2 ++ src/SuperLoop/CMakeLists.txt | 7 ++++++ src/SuperLoop/SuperLoop.c | 15 ++++++++++++ src/SuperLoop/SuperLoop.h | 19 +++++++++++++++ src/main.c | 1 + tests/AllTests.cpp | 1 + tests/CMakeLists.txt | 2 ++ tests/SuperLoop/CMakeLists.txt | 10 ++++++++ tests/SuperLoop/test_SuperLoop.cpp | 38 ++++++++++++++++++++++++++++++ 9 files changed, 95 insertions(+) create mode 100644 src/SuperLoop/CMakeLists.txt create mode 100644 src/SuperLoop/SuperLoop.c create mode 100644 src/SuperLoop/SuperLoop.h create mode 100644 tests/SuperLoop/CMakeLists.txt create mode 100644 tests/SuperLoop/test_SuperLoop.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4fb274..2d9557a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,7 @@ add_executable(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} RegEdit + SuperLoop timer LedController ) @@ -53,3 +54,4 @@ add_subdirectory(RegEdit) add_subdirectory(usart) add_subdirectory(timer) add_subdirectory(LedController) +add_subdirectory(SuperLoop) diff --git a/src/SuperLoop/CMakeLists.txt b/src/SuperLoop/CMakeLists.txt new file mode 100644 index 0000000..9275283 --- /dev/null +++ b/src/SuperLoop/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(SuperLoop STATIC + SuperLoop.c +) + +target_include_directories(SuperLoop PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/src/SuperLoop/SuperLoop.c b/src/SuperLoop/SuperLoop.c new file mode 100644 index 0000000..41dc003 --- /dev/null +++ b/src/SuperLoop/SuperLoop.c @@ -0,0 +1,15 @@ +/* + * Author: username + * Date: 2024 + * filename: SuperLoop.c + * description: module_purpose + */ + +#include "SuperLoop.h" + +// dumb test function +int add_two(int a) { + int b = a; + b += 2; + return b; +} diff --git a/src/SuperLoop/SuperLoop.h b/src/SuperLoop/SuperLoop.h new file mode 100644 index 0000000..1b2124d --- /dev/null +++ b/src/SuperLoop/SuperLoop.h @@ -0,0 +1,19 @@ +/** + * @brief PUT_TEXT_HERE + * @details This file is... + * @author username + * @date todays_date + * @copyright None + * @file SUPERLOOP.h + */ + +#ifndef SUPERLOOP +#define SUPERLOOP + +/** + * A function that adds two to a number + * @param a The first argument + */ +int add_two(int a); + +#endif // SUPERLOOP diff --git a/src/main.c b/src/main.c index 0082491..3a1bf1f 100644 --- a/src/main.c +++ b/src/main.c @@ -17,6 +17,7 @@ #include "LedController.h" #include "RegEdit.h" +#include "SuperLoop.h" #include "config.h" #include "timer.h" #include /* Required header file */ diff --git a/tests/AllTests.cpp b/tests/AllTests.cpp index 58628d0..01b7c9e 100644 --- a/tests/AllTests.cpp +++ b/tests/AllTests.cpp @@ -3,6 +3,7 @@ //ImportTestGroups IMPORT_TEST_GROUP(simple_test); +IMPORT_TEST_GROUP(test_SuperLoop); IMPORT_TEST_GROUP(test_RegEdit); IMPORT_TEST_GROUP(test_LedController); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ea030d6..fe6e229 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,7 @@ project(Tests) # TEST_DIRS +add_subdirectory(SuperLoop) #add_subdirectory(timer) #add_subdirectory(usart) add_subdirectory(MockRegEdit) @@ -21,6 +22,7 @@ target_link_libraries(AllTests ${CPPUTEST_LIBRARIES}/libCppUTest.a ${CPPUTEST_LIBRARIES}/libCppUTestExt.a # TEST_LINKS + test_SuperLoop test_LedController #test_timer test_RegEdit diff --git a/tests/SuperLoop/CMakeLists.txt b/tests/SuperLoop/CMakeLists.txt new file mode 100644 index 0000000..30a7c5e --- /dev/null +++ b/tests/SuperLoop/CMakeLists.txt @@ -0,0 +1,10 @@ +# TEST_RUNNER +add_library(test_SuperLoop + test_SuperLoop.cpp +) + +target_link_libraries(test_SuperLoop + ${CPPUTEST_LIBRARIES}/libCppUTest.a + ${CPPUTEST_LIBRARIES}/libCppUTestExt.a + SuperLoop +) diff --git a/tests/SuperLoop/test_SuperLoop.cpp b/tests/SuperLoop/test_SuperLoop.cpp new file mode 100644 index 0000000..4b91d33 --- /dev/null +++ b/tests/SuperLoop/test_SuperLoop.cpp @@ -0,0 +1,38 @@ +/* + * Author: Jake G + * Date: 2024-09-01 + * filename: test_SuperLoop.c + * description: module_purpose + */ + +#include "CppUTest/CommandLineTestRunner.h" + +extern "C" +{ +#include "SuperLoop.h" +} + +TEST_GROUP(test_SuperLoop) +{ + void setup() + { + + } + void teardown() + { + + } +}; + +TEST(test_SuperLoop, FirstTest) +{ + FAIL("Fail me!"); +} + +TEST(test_SuperLoop, SecondTest) +{ + STRCMP_EQUAL("hello", "world"); + LONGS_EQUAL(1, 2); + CHECK(false); +} +