commit 923a8b8c87184c6c7a5ea1c032368d2b4d87b477 Author: Trianta Date: Mon Oct 9 10:16:02 2023 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..129f2a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# ---> C++ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# CMake +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..da0b217 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) + +project( + something + LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use") +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +add_subdirectory(src) + +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + add_subdirectory(test) +endif() diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..74f552d --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# cpp-unity-template + +## Compiling the project + +Prerequisites + - C++11 + +In order to compile the project, simply run these two commands: + + cmake -B build -S . + cmake --build build + +## Running the Project +The program should now be compiled at ./build/bin/something + +Simply run the program using: + + build/bin/something + +## Testing the Project +In order to compile the tests for the project, simply run these two commands: + + cmake -DCMAKE_BUILD_TYPE=Debug -B build -S . + cmake --build build + +The program should now be compiled at ./build/bin/somethingTest + +Simply run the tests using: + + build/bin/somethingTest \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..4a2d7eb --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(something + ./main.cpp +) + +target_include_directories(something PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..29b2fa0 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,6 @@ +#include + +int main(void) { + std::cout << "Hello world" << std::endl; + return 0; +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..8a65233 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(unity REQUIRED) +include_directories(${CMAKE_SOURCE_DIR}/src) +add_executable(testing + test.cpp +) +set_target_properties(testing PROPERTIES LINKER_LANGUAGE CXX) +target_link_libraries(testing unity) diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 0000000..6668b68 --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,21 @@ +#include +#include + +void setUp() { ; } +void tearDown() { ; } + +int Math(void) { + return 2+2; +} + +void test_Math(void) { + TEST_ASSERT_EQUAL_INT(4, Math()); +} + + +int main(void) { + UNITY_BEGIN(); + RUN_TEST(test_Math); + return UNITY_END(); +} +