Skip to content

Commit

Permalink
test(core): cover std::unordered_map reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 26, 2023
1 parent 72cb5da commit a021941
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_executable(
reflection/traits/constructible.cpp
reflection/external/primitives.cpp
reflection/external/map.cpp
reflection/external/unordered_map.cpp

data/fs/embedded_archive.cpp
data/fs/standard_archive.cpp
Expand Down
25 changes: 25 additions & 0 deletions core/tests/reflection/external/unordered_map.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <doctest/doctest.h>

#include <cubos/core/reflection/external/primitives.hpp>
#include <cubos/core/reflection/external/unordered_map.hpp>

#include "../traits/constructible.hpp"
#include "../traits/dictionary.hpp"

template <typename K, typename V>
static void test(const char* name, std::unordered_map<K, V> map, K insertedKey, V insertedValue)
{
CHECK(reflect<std::unordered_map<K, V>>().name() == name);
testDictionary<std::unordered_map<K, V>, K, V>(map, map.size(), &insertedKey, &insertedValue);
testConstructible<std::unordered_map<K, V>>(&map);
}

TEST_CASE("reflection::reflect<std::unordered_map<K, V>>()")
{
test<int32_t, int32_t>("std::unordered_map<int32_t, int32_t>", {{1, 2}, {2, 4}}, 3, 6);
test<char, std::unordered_map<char, bool>>("std::unordered_map<char, std::unordered_map<char, bool>>",
{
{'H', {{'i', true}, {'o', false}}},
},
'A', {{'h', true}});
}

0 comments on commit a021941

Please sign in to comment.