TestHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
7 
8 #include "Utilities/TMPL.hpp"
9 #include "Utilities/TaggedTuple.hpp"
10 
11 namespace TestHelpers {
12 /// \ingroup TestingFrameworkGroup
13 /// Functions for testing analytic solutions
14 namespace AnalyticSolutions {
15 /// Checks that tags can be retrieved both individually and all at
16 /// once.
17 template <typename Solution, typename Coords, typename TagsList>
18 void test_tag_retrieval(const Solution& solution, const Coords& coords,
19  const double time, const TagsList /*meta*/) noexcept {
20  const auto vars_from_all_tags = solution.variables(coords, time, TagsList{});
21  const auto vars_from_all_tags_reversed =
22  solution.variables(coords, time, tmpl::reverse<TagsList>{});
23  tmpl::for_each<TagsList>([&](const auto tag_v) noexcept {
24  using tag = tmpl::type_from<decltype(tag_v)>;
25  const auto single_var = solution.variables(coords, time, tmpl::list<tag>{});
26  CHECK(tuples::get<tag>(single_var) == tuples::get<tag>(vars_from_all_tags));
27  CHECK(tuples::get<tag>(single_var) ==
28  tuples::get<tag>(vars_from_all_tags_reversed));
29  });
30 }
31 } // namespace AnalyticSolutions
32 } // namespace TestHelpers
Definition: TestCreation.hpp:14
Wraps the template metaprogramming library used (brigand)
Code to wrap or improve the Catch testing framework used for unit tests.
void test_tag_retrieval(const Solution &solution, const Coords &coords, const double time, const TagsList) noexcept
Checks that tags can be retrieved both individually and all at once.
Definition: TestHelpers.hpp:18