Added test structure and Unity usage
This commit is contained in:
parent
c58349f9cb
commit
10c7f5cc1c
2
.gitignore
vendored
2
.gitignore
vendored
@ -32,3 +32,5 @@
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
build
|
||||||
|
16
CMakeLists.txt
Normal file
16
CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
project(
|
||||||
|
search-algorithms
|
||||||
|
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()
|
6
src/main.cpp
Normal file
6
src/main.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
std::cout << "Hello world" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
7
test/CMakeLists.txt
Normal file
7
test/CMakeLists.txt
Normal 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
21
test/test.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user