aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-09-03 19:51:41 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-09-03 19:51:41 +0200
commit287ade1d321c983ddd00025864f9ea59d31c4493 (patch)
treee0722c1ce91355762ffb05e482f958c7bbd5e777
parentc818aa8a02d2809b3189a1fdbec580fd59d22ce2 (diff)
add googletest unit testing setup
-rw-r--r--.gitmodules5
-rw-r--r--contributing.md9
m---------lib/googletest0
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--test/CMakeLists.txt21
-rw-r--r--test/dummy.cpp6
-rw-r--r--test/makefile7
7 files changed, 49 insertions, 1 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f8a9861
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,5 @@
+[submodule "lib/googletest"]
+ path = lib/googletest
+ url = https://github.com/google/googletest
+ branch = v1.15.x
+ shallow = true
diff --git a/contributing.md b/contributing.md
index c018917..f8c7d97 100644
--- a/contributing.md
+++ b/contributing.md
@@ -17,6 +17,13 @@
sure to separate the include statements using a blank line (clang-format may
sort include statements, but does not sort across empty lines).
+## CMakeLists specific
+
+- Make sure list arguments (e.g. sources, libraries) given to commands (e.g.
+ `target_sources`, `target_link_libraries`) are on separate lines. This makes
+ resolving merge conflicts when multiple sources were added by different
+ people to the same CMakeLists.txt easier.
+
# Documentation
- All documentation is written in U.S. English
@@ -26,4 +33,6 @@
- External libraries should be included as Git submodules under the `lib/`
subdirectory
+- When adding new submodules, make sure to manually set the `branch` and
+ `shallow` options in the [.gitmodules](./.gitmodules) file
diff --git a/lib/googletest b/lib/googletest
new file mode 160000
+Subproject b514bdc898e2951020cbdca1304b75f5950d1f5
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3ade1e3..0090188 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.28)
set(CMAKE_C_STANDARD 11)
-set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# enable debug features
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..26aa460
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.28)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+
+set(CMAKE_BUILD_TYPE Debug)
+
+project(test C CXX)
+
+add_subdirectory(../lib/googletest googletest)
+
+add_executable(test
+ dummy.cpp
+)
+
+target_link_libraries(test
+ gtest_main
+ # TODO: add crepe engine
+)
+
diff --git a/test/dummy.cpp b/test/dummy.cpp
new file mode 100644
index 0000000..08850b2
--- /dev/null
+++ b/test/dummy.cpp
@@ -0,0 +1,6 @@
+#include <gtest/gtest.h>
+
+TEST(dummy, foo) {
+ ASSERT_TRUE(1);
+}
+
diff --git a/test/makefile b/test/makefile
new file mode 100644
index 0000000..7aeee34
--- /dev/null
+++ b/test/makefile
@@ -0,0 +1,7 @@
+TARGET = $(BUILD_DIR)/test
+
+include ../lazy.mk
+
+test: $(TARGET) FORCE
+ $(TARGET)
+