From 49a69d52da71b6a2451365b30c802021748d312b Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Wed, 27 Nov 2024 16:37:57 +0100 Subject: [PATCH] Add cartesian_product_t tests (#690) --- include/ddc/discrete_domain.hpp | 25 +++++++++---------------- tests/discrete_domain.cpp | 8 ++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/ddc/discrete_domain.hpp b/include/ddc/discrete_domain.hpp index 84e49efeb..c7ab39896 100644 --- a/include/ddc/discrete_domain.hpp +++ b/include/ddc/discrete_domain.hpp @@ -393,19 +393,19 @@ using convert_type_seq_to_discrete_domain_t = typename ConvertTypeSeqToDiscreteD // Computes the cartesian product of DiscreteDomain types // Example usage : "using DDom = cartesian_prod_t;" -template +template struct cartesian_prod; -template -struct cartesian_prod, ddc::DiscreteDomain> +template +struct cartesian_prod, DiscreteDomain, DDomsTail...> { - using type = ddc::DiscreteDomain; + using type = typename cartesian_prod, DDomsTail...>::type; }; -template -struct cartesian_prod +template +struct cartesian_prod> { - using type = DDom; + using type = DiscreteDomain; }; template <> @@ -414,15 +414,8 @@ struct cartesian_prod<> using type = ddc::DiscreteDomain<>; }; -template -struct cartesian_prod -{ - using type = - typename cartesian_prod::type, Tail...>::type; -}; - -template -using cartesian_prod_t = typename cartesian_prod::type; +template +using cartesian_prod_t = typename cartesian_prod::type; // Computes the substraction DDom_a - DDom_b in the sense of linear spaces(retained dimensions are those in DDom_a which are not in DDom_b) template diff --git a/tests/discrete_domain.cpp b/tests/discrete_domain.cpp index 949e0a933..6acc8c120 100644 --- a/tests/discrete_domain.cpp +++ b/tests/discrete_domain.cpp @@ -287,3 +287,11 @@ TEST(DiscreteDomainTest, Transpose3DConstructor) EXPECT_EQ(ddc::select(dom_x_y_z.back()), ddc::select(dom_z_y_x.back())); EXPECT_EQ(ddc::select(dom_x_y_z.back()), ddc::select(dom_z_y_x.back())); } + +TEST(DiscreteDomainTest, CartesianProduct) +{ + EXPECT_TRUE((std::is_same_v, ddc::DiscreteDomain<>>)); + EXPECT_TRUE((std::is_same_v, DDomX>)); + EXPECT_TRUE((std::is_same_v, DDomXYZ>)); + EXPECT_TRUE((std::is_same_v, DDomZYX>)); +}