From 7af9b60d49f70624f80bf2e54f399bb37cb94927 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Thu, 4 Aug 2022 08:50:47 +0000 Subject: [PATCH 1/2] Fix get_keys of empty hymap --- include/gridtools/common/hymap.hpp | 1 + tests/unit_tests/common/test_hymap.cpp | 29 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/gridtools/common/hymap.hpp b/include/gridtools/common/hymap.hpp index f410874d9..6ea750a18 100644 --- a/include/gridtools/common/hymap.hpp +++ b/include/gridtools/common/hymap.hpp @@ -256,6 +256,7 @@ namespace gridtools { template <> struct keys<>::values<> { friend values tuple_getter(values const &) { return {}; } + friend keys hymap_get_keys(values const &) { return {}; } }; template diff --git a/tests/unit_tests/common/test_hymap.cpp b/tests/unit_tests/common/test_hymap.cpp index 0775dcc05..b2f6966b0 100644 --- a/tests/unit_tests/common/test_hymap.cpp +++ b/tests/unit_tests/common/test_hymap.cpp @@ -15,6 +15,7 @@ #include +#include #include #include @@ -32,6 +33,13 @@ namespace gridtools { static_assert(is_hymap::values>::value); static_assert(is_hymap::values>::value); + static_assert(std::is_same_v>, + meta::list, integral_constant>>); + static_assert(std::is_same_v>, + meta::list, integral_constant>>); + static_assert(std::is_same_v::values<>>, hymap::keys<>>); + static_assert(std::is_same_v::values>, hymap::keys>); + TEST(tuple_like, smoke) { using testee_t = hymap::keys::values; @@ -188,7 +196,26 @@ namespace gridtools { EXPECT_EQ(16, at_key(testee)); } - TEST(assingment, smoke) { + TEST(concat, smoke) { + auto m1 = hymap::keys::make_values(1, 2); + auto m2 = hymap::keys::make_values(3.5); + auto testee = hymap::concat(m1, m2); + + EXPECT_EQ(1, at_key(testee)); + EXPECT_EQ(2, at_key(testee)); + EXPECT_EQ(3.5, at_key(testee)); + } + + TEST(concat, empty) { + auto m1 = hymap::keys<>::make_values(); + auto m2 = hymap::keys::make_values(42); + + auto testee = hymap::concat(m1, m2); + + EXPECT_EQ(42, at_key(testee)); + } + + TEST(assignment, smoke) { hymap::keys::values testee; auto src = hymap::keys::make_values(88, 3.5, 16); testee = src; From e2f9345c73f43e2eed8eab6c08614c73619afa56 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Thu, 4 Aug 2022 08:52:23 +0000 Subject: [PATCH 2/2] remove an empty line --- tests/unit_tests/common/test_hymap.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit_tests/common/test_hymap.cpp b/tests/unit_tests/common/test_hymap.cpp index b2f6966b0..f117e169b 100644 --- a/tests/unit_tests/common/test_hymap.cpp +++ b/tests/unit_tests/common/test_hymap.cpp @@ -209,7 +209,6 @@ namespace gridtools { TEST(concat, empty) { auto m1 = hymap::keys<>::make_values(); auto m2 = hymap::keys::make_values(42); - auto testee = hymap::concat(m1, m2); EXPECT_EQ(42, at_key(testee));