Skip to content

Commit

Permalink
fix(cmakelists): add new unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealPad committed Feb 28, 2024
1 parent 889d320 commit 2b354da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
build/
cmake-build-debug/

johnDoe
unit_test
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(Calculator VERSION 1.0
DESCRIPTION "I love C++"
LANGUAGES CXX)

SET(NAME "calculator")
SET(NAME "johnDoe")
SET(TEST_NAME "unit_test")

set(CMAKE_CXX_STANDARD 17)
Expand All @@ -17,9 +17,9 @@ set(SRC
)

set(TEST_SRC
src/Error/Error.cpp
tests/test.cpp
tests/Error.cpp
tests/Calculator.cpp
)

add_executable(${NAME} main.cpp ${SRC})
Expand All @@ -39,11 +39,14 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(googletest)

add_executable(${TEST_NAME} ${TEST_SRC})
add_executable(${TEST_NAME} ${SRC} ${TEST_SRC})
target_link_libraries(${TEST_NAME} PUBLIC gtest_main)

include(CTest)
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})

set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})

include_directories(${TEST_NAME} PUBLIC src/Calculator)
include_directories(${TEST_NAME} PUBLIC src/Error)
7 changes: 7 additions & 0 deletions tests/Calculator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <gtest/gtest.h>
#include "Calculator.h"

TEST(Calculator, ThrowDivisionError)
{
EXPECT_EQ(true, true);
}

0 comments on commit 2b354da

Please sign in to comment.