Skip to content

Commit 326e676

Browse files
committed
Upgrade Catch2
1 parent b2682d7 commit 326e676

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ cmake_minimum_required(VERSION 3.20)
22

33
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
44
set(CMAKE_TOOLCHAIN_FILE
5-
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
6-
CACHE STRING "")
5+
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
6+
CACHE STRING "")
77
endif()
8+
89
message(STATUS "TOOLCHAIN: ${CMAKE_TOOLCHAIN_FILE}")
910

1011
project(FrameGraph)
12+
1113
if(PROJECT_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR)
1214
message(
1315
FATAL_ERROR
14-
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
16+
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
1517
)
1618
endif()
1719

@@ -25,11 +27,10 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
2527
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") # .lib
2628
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") # .dll
2729
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") # .exe
28-
29-
option(BUILD_SHARED_LIBS "Use shared libraries" OFF)
30-
set(BUILD_TESTING ON)
3130
endif()
3231

32+
option(FG_BUILD_TEST ON)
33+
3334
add_library(
3435
FrameGraph
3536
"include/fg/TypeTraits.hpp"
@@ -57,11 +58,13 @@ target_include_directories(
5758

5859
add_library(fg::FrameGraph ALIAS FrameGraph)
5960

60-
if(BUILD_TESTING)
61+
if(FG_BUILD_TEST)
6162
enable_testing()
6263
add_subdirectory(tests)
6364
endif()
6465

6566
include(GNUInstallDirs)
66-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/fg
67-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
67+
install(
68+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/fg
69+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
70+
)

tests/test.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#define CATCH_CONFIG_MAIN
21
#include "fg/FrameGraph.hpp"
32
#include "fg/Blackboard.hpp"
4-
#include "catch2/catch.hpp"
3+
#include "catch.hpp"
4+
#include <fstream>
55

66
struct BadResource {
77
struct Desc {};
@@ -265,18 +265,26 @@ TEST_CASE("Blackboard", "[Blackboard]") {
265265
};
266266
bb.add<FooData>() = {1, 2, 3};
267267
REQUIRE(bb.has<FooData>());
268+
REQUIRE(bb.try_get<FooData>());
269+
270+
auto *foo = bb.try_get<FooData>();
268271

269272
struct BarData {
270273
int32_t i, j, k;
271274
};
272275
bb.add<BarData>(9, 8, 7);
273276
REQUIRE(bb.has<BarData>());
274277

275-
CHECK(bb.get<FooData>().x == 1);
276-
CHECK(bb.get<FooData>().y == 2);
277-
CHECK(bb.get<FooData>().z == 3);
278-
279278
CHECK(bb.get<BarData>().i == 9);
280279
CHECK(bb.get<BarData>().j == 8);
281280
CHECK(bb.get<BarData>().k == 7);
281+
282+
CHECK(foo->x == 1);
283+
CHECK(foo->y == 2);
284+
CHECK(foo->z == 3);
285+
286+
foo->x = 100;
287+
CHECK(bb.get<FooData>().x == 100);
282288
}
289+
290+
int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }

0 commit comments

Comments
 (0)