Skip to content

Commit

Permalink
Add meta context visitor test utility
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Nov 18, 2023
1 parent 958e73f commit 05b8061
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
67 changes: 67 additions & 0 deletions modules/core/test/testutil/meta_context_visitor_tester.hpp
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 05b8061

Please sign in to comment.