Skip to content

Commit

Permalink
Set up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Apr 5, 2024
1 parent 0fa6f8b commit c2d084c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,29 @@ cmake_minimum_required(VERSION 3.28)
project(LiteStr C CXX)

set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Google Test requires at least C++14
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Additional options for the Debug build
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wpedantic")

add_library(LiteStr STATIC lite_str.h lite_str.c)

# Google Test
include(FetchContent)

FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/f10e11fb27301fba21caa71030bb5024e67aa135.zip
)

FetchContent_MakeAvailable(googletest)

enable_testing()

# Tests
add_subdirectory(tests)
13 changes: 13 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Test executable
add_executable(testLiteString
testLiteString.cpp
../lite_str.h
../lite_str.c)

# Link with gtest
target_link_libraries(testLiteString gtest gtest_main)

include(GoogleTest)

# Discover tests
gtest_discover_tests(testLiteString)

0 comments on commit c2d084c

Please sign in to comment.