From 1f39fc8366609ccbf7cda4e631dcd93175acb3ce Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Thu, 14 Sep 2023 14:20:21 -0500 Subject: [PATCH] Cleaned up repo --- .gitignore | 2 ++ README.md | 12 ++++++++++++ test/CMakeLists.txt | 7 +++++++ test/mt_web_server.cpp | 4 ++-- test/test.cpp | 28 ++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 test/test.cpp diff --git a/.gitignore b/.gitignore index e257658..ee52d22 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ *.out *.app +# Extras +build diff --git a/README.md b/README.md index 1b63240..c72bbe3 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,15 @@ The program should now be compiled at ./build/bin/proxy-network Simply run the program using: build/bin/proxy-network + +## Testing the Project +The Unity framework is used for testing + +Build the tests using: + + cmake -DCMAKE_BUILD_TYPE=Debug -B build -S . + cmake --build build + +Then run the tests using: + + build/bin/testing diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e69de29..bb1f7c7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -0,0 +1,7 @@ +add_subdirectory(Unity) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(testing + ./test.cpp +) +set_target_properties(testing PROPERTIES LINKER_LANGUAGE CXX) +target_link_libraries(testing unity) diff --git a/test/mt_web_server.cpp b/test/mt_web_server.cpp index de95e9e..e5ebba8 100644 --- a/test/mt_web_server.cpp +++ b/test/mt_web_server.cpp @@ -28,7 +28,7 @@ //= History: KJC (12/29/00) - Genesis (from server.c) = //= HF (01/25/01) - Ported to multi-platform environment = //============================================================================= -#define WIN // WIN for Windows environment, UNIX for BSD or LINUX env. +#define UNIX // WIN for Windows environment, UNIX for BSD or LINUX env. //----- Include files --------------------------------------------------------- #include // Needed for printf() @@ -301,4 +301,4 @@ void child_proc(int server_s, int client_s) close(client_s); } #endif -/* ----------------------------------------------------------------------- */ \ No newline at end of file +/* ----------------------------------------------------------------------- */ diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 0000000..326bdab --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,28 @@ +#include +#include + +int math(); +void test_math(); +void IsEqual(bool lhs, bool rhs); + +int main() { + test_math(); + return 0; +} + +int math() { + return 2+2; +} + +void test_math() { + IsEqual(math(), 4); + IsEqual(math(), 6); +} + +void IsEqual(bool lhs, bool rhs) { + if (lhs == rhs) { + std::cout << "Test Success" << std::endl; + } else { + std::cout << "Test Failure" << std::endl; + } +}