Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/googletest"]
path = external/googletest
url = https://github.com/google/googletest.git
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ add_compile_options(-Wall -Wextra -Werror)

add_executable(main "${SRC_DIR}/main.cpp" "${SRC_DIR}/two-sum.cpp")

find_package(GTest REQUIRED)
# Fetch Google Test
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
)
FetchContent_MakeAvailable(googletest)

add_executable(two-sum-test "${TEST_DIR}/test.cpp" "${SRC_DIR}/two-sum.cpp")
target_link_libraries(two-sum-test PRIVATE gtest::gtest)
target_link_libraries(two-sum-test gtest gtest_main)
target_compile_options(two-sum-test PRIVATE "-fsanitize=address,undefined")
target_link_options(two-sum-test PRIVATE "-fsanitize=address,undefined")

add_test(NAME two-sum-test COMMAND two-sum-test)
include(GoogleTest)
gtest_discover_tests(two-sum-test)
Loading