Initial commit

This commit is contained in:
Trianta 2023-10-09 10:16:02 -05:00
commit 923a8b8c87
8 changed files with 130 additions and 0 deletions

36
.gitignore vendored Normal file
View File

@ -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

16
CMakeLists.txt Normal file
View File

@ -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()

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
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.

30
README.md Normal file
View File

@ -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

5
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
add_executable(something
./main.cpp
)
target_include_directories(something PUBLIC ${CMAKE_CURRENT_LIST_DIR})

6
src/main.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <iostream>
int main(void) {
std::cout << "Hello world" << std::endl;
return 0;
}

7
test/CMakeLists.txt Normal file
View File

@ -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)

21
test/test.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <unity/unity.h>
#include <unity/unity_internals.h>
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();
}