From bb18a102ef73a791c493321234b0cf453b2333fb Mon Sep 17 00:00:00 2001 From: Nino Maruszewski Date: Tue, 18 Jul 2023 14:51:13 -0500 Subject: [PATCH 1/2] test: convert to gtest --- CMakeLists.txt | 5 ----- CMakePresets.json | 2 +- conanfile.py | 2 +- test/CMakeLists.txt | 8 ++++---- test/src/raccoon_test.cpp | 11 +++++++++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93de259..b3a67a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,11 +16,6 @@ include(cmake/variables.cmake) configure_file(src/config.h.in config.h) -############################### -# XXX DISABLE TESTING FOR NOW # -############################### -set(BUILD_TESTING OFF) - # ---- Declare library ---- add_library( diff --git a/CMakePresets.json b/CMakePresets.json index bb04e4d..e477aef 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -26,7 +26,7 @@ "hidden": true, "inherits": "cmake-pedantic", "cacheVariables": { - "NUTC24_DEVELOPER_MODE": "ON" + "raccoon_DEVELOPER_MODE": "ON" } }, { diff --git a/conanfile.py b/conanfile.py index e3c73ba..da47112 100644 --- a/conanfile.py +++ b/conanfile.py @@ -21,7 +21,7 @@ def requirements(self): self.requires("argparse/2.9") # argument parsing def build_requirements(self): - self.test_requires("catch2/3.3.1") + self.test_requires("gtest/1.13.0") def configure(self): if self.settings.os == 'Windows': diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6cd6bbb..8315066 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,8 +6,8 @@ project(raccoonTests LANGUAGES CXX) # ---- Dependencies ---- -find_package(Catch2 REQUIRED) -include(Catch) +find_package(GTest REQUIRED) +include(GoogleTest) # ---- Tests ---- @@ -15,11 +15,11 @@ add_executable(raccoon_test src/raccoon_test.cpp) target_link_libraries( raccoon_test PRIVATE raccoon_lib - Catch2::Catch2WithMain + GTest::gtest_main ) target_compile_features(raccoon_test PRIVATE cxx_std_20) -catch_discover_tests(raccoon_test) +gtest_discover_tests(raccoon_test) # ---- End-of-file commands ---- diff --git a/test/src/raccoon_test.cpp b/test/src/raccoon_test.cpp index 165863c..6e4dcb6 100644 --- a/test/src/raccoon_test.cpp +++ b/test/src/raccoon_test.cpp @@ -1,3 +1,10 @@ -#include +#include -TEST_CASE("Name is raccoon", "[library]") {} +// Demonstrate some basic assertions. +TEST(HelloTest, BasicAssertions) { + // Expect two strings not to be equal. + EXPECT_STRNE("hello", "world"); + + // Expect equality. + EXPECT_EQ(7 * 6, 42); +} From a0b5f170fc2061116ba252a2a96235b69a1bb1fc Mon Sep 17 00:00:00 2001 From: Nino Maruszewski Date: Tue, 18 Jul 2023 14:52:59 -0500 Subject: [PATCH 2/2] style: formatting --- test/src/raccoon_test.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/src/raccoon_test.cpp b/test/src/raccoon_test.cpp index 6e4dcb6..eef0077 100644 --- a/test/src/raccoon_test.cpp +++ b/test/src/raccoon_test.cpp @@ -1,10 +1,11 @@ #include // Demonstrate some basic assertions. -TEST(HelloTest, BasicAssertions) { - // Expect two strings not to be equal. - EXPECT_STRNE("hello", "world"); +TEST(HelloTest, BasicAssertions) +{ + // Expect two strings not to be equal. + EXPECT_STRNE("hello", "world"); - // Expect equality. - EXPECT_EQ(7 * 6, 42); + // Expect equality. + EXPECT_EQ(7 * 6, 42); }