Sequoia
Loading...
Searching...
No Matches
PhysicalValueTestingUtilities.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2024. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
14
15namespace sequoia::testing
16{
17 template<
18 maths::convex_space PhysicalValueSpace,
19 physics::physical_unit Unit,
20 maths::basis_for<maths::free_module_type_of_t<PhysicalValueSpace>> Basis,
21 class Origin,
22 class Validator
23 >
24 struct value_tester<physics::physical_value<PhysicalValueSpace, Unit, Basis, Origin, Validator>>
25 {
27 using value_type = type::value_type;
28 constexpr static auto dimension{type::dimension};
29
30 template<test_mode Mode>
31 static void test(equality_check_t, test_logger<Mode>& logger, const type& actual, const type& prediction)
32 {
33 if constexpr(dimension == 1)
34 {
35 check(equality, "Wrapped Value", logger, actual.value(), prediction.value());
36 }
37 else
38 {
39 check(equality, "Wrapped Values", logger, actual.values(), prediction.values());
40 }
41 }
42
43 template<test_mode Mode>
44 requires (dimension == 1)
45 static void test(equivalence_check_t, test_logger<Mode>& logger, const type& actual, const value_type& prediction)
46 {
47 check(equality, "Wrapped Value", logger, actual.value(), prediction);
48 }
49
50 template<test_mode Mode>
51 requires (dimension > 1)
52 static void test(equivalence_check_t, test_logger<Mode>& logger, const type& actual, const std::array<value_type, dimension>& prediction)
53 {
54 check(equivalence, "Wrapped Values", logger, actual.values(), prediction);
55 }
56 };
57
58 template<
59 maths::convex_space ValueSpace,
60 class Unit,
62 class Origin,
63 class Validator
64 >
65 inline constexpr bool defines_physical_value_v{
66 requires {
68 }
69 };
70}
bool check(CheckType flavour, std::string description, test_logger< Mode > &logger, Iter first, Sentinel last, PredictionIter predictionFirst, PredictionSentinel predictionLast, tutor< Advisor > advisor={})
The workhorse for comparing the contents of ranges.
Definition: FreeCheckers.hpp:377
Utilities for checking regular semantics.
Definition: PhysicalValues.hpp:451
Definition: TestLogger.hpp:183
A concept to determine if a basis is appropriate for a particular free module.
Definition: Spaces.hpp:620
concept for convex spaces
Definition: Spaces.hpp:517
Definition: FreeCheckers.hpp:82
Definition: FreeCheckers.hpp:87
class template, specializations of which implement various comparisons for the specified type.
Definition: FreeCheckers.hpp:78