From 05b80617199ddf50020a954427530e2c9c0a816e Mon Sep 17 00:00:00 2001 From: Albin Johansson Date: Sat, 18 Nov 2023 15:06:37 +0100 Subject: [PATCH] Add meta context visitor test utility --- modules/core/CMakeLists.txt | 5 ++ .../testutil/meta_context_visitor_tester.hpp | 67 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 modules/core/test/testutil/meta_context_visitor_tester.hpp diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index ad8bca1ea5..44578ae7e9 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -57,6 +57,11 @@ if (TACTILE_BUILD_TESTS MATCHES ON) tactile_prepare_target(${TACTILE_CORE_TEST_TARGET}) + target_include_directories(${TACTILE_CORE_TEST_TARGET} + PRIVATE + "${TACTILE_CORE_DIR}/test" + ) + target_link_libraries(${TACTILE_CORE_TEST_TARGET} PRIVATE ${TACTILE_CORE_TARGET} diff --git a/modules/core/test/testutil/meta_context_visitor_tester.hpp b/modules/core/test/testutil/meta_context_visitor_tester.hpp new file mode 100644 index 0000000000..c634246f97 --- /dev/null +++ b/modules/core/test/testutil/meta_context_visitor_tester.hpp @@ -0,0 +1,67 @@ +// Copyright (C) 2023 Albin Johansson (GNU General Public License v3.0) + +#pragma once + +#include "tactile/core/context/meta_context_visitor.hpp" + +namespace tactile::testutil { + +class MetaContextVisitorTester final : public IMetaContextVisitor { + public: + int orthogonal_map_count {0}; + int isometric_map_count {0}; + int hexagonal_map_count {0}; + int group_layer_count {0}; + int tile_layer_count {0}; + int object_layer_count {0}; + int object_count {0}; + int tileset_count {0}; + int tile_count {0}; + + void visit([[maybe_unused]] OrthogonalMap& map) override + { + ++orthogonal_map_count; + } + + void visit([[maybe_unused]] IsometricMap& map) override + { + ++isometric_map_count; + } + + void visit([[maybe_unused]] HexagonalMap& map) override + { + ++hexagonal_map_count; + } + + void visit([[maybe_unused]] GroupLayer& layer) override + { + ++group_layer_count; + } + + void visit([[maybe_unused]] TileLayer& layer) override + { + ++tile_layer_count; + } + + void visit([[maybe_unused]] ObjectLayer& layer) override + { + ++object_layer_count; + } + + void visit([[maybe_unused]] Object& object) override + { + ++object_count; + } + + void visit([[maybe_unused]] Tileset& tileset) override + { + ++tileset_count; + } + + void visit([[maybe_unused]] Tile& tile) override + { + ++tile_count; + } +}; + +} // namespace tactile::testutil