From ae912c0efbf50dfd450661b7bd065492a0af447c Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Sun, 12 May 2024 11:47:03 +0200 Subject: [PATCH] added one more test; highlighting an issue with detail::common_magnitude_type_impl when both types are the same --- test/static/quantity_point_test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/static/quantity_point_test.cpp b/test/static/quantity_point_test.cpp index 7c0e001c..ef2520d1 100644 --- a/test/static/quantity_point_test.cpp +++ b/test/static/quantity_point_test.cpp @@ -1706,9 +1706,21 @@ static_assert(value_cast_is_forbidden, quantity_point, quantity_point>(), "value_cast shall not cast between different quantity types"); +// value_cast which does not touch the point_origin +static_assert(value_cast>(quantity_point{2 * isq::height[km]}) + .quantity_from_origin_is_an_implementation_detail_.numerical_value_in(m) == 2000); +static_assert(value_cast>(quantity_point{2000 * isq::height[m]}) + .quantity_from_origin_is_an_implementation_detail_.numerical_value_in(km) == 2); +// a value_cast which includes a change to the point origin +static_assert(value_cast>(quantity_point{2000 * isq::height[m], + ground_level}) + .quantity_from_origin_is_an_implementation_detail_.numerical_value_in(m) == 2042); +// a value_cast which includes a change to the point origin as-well as a change in units static_assert(value_cast>(quantity_point{2 * isq::height[km], ground_level}) .quantity_from_origin_is_an_implementation_detail_.numerical_value_in(m) == 2042); +// a value_cast which changes all three of unit, rep, point_origin simultaneously, and the range of either FromQP or +// ToQP does not include the other's point_origin static_assert(value_cast>( quantity_point{std::int8_t{100} * isq::height[mm], ground_level}) .quantity_from_origin_is_an_implementation_detail_.numerical_value_in(cm) == 4210);