From be8fc9eb984bd1ff2ba3e4aa3da1f734e4677353 Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Fri, 10 May 2024 22:38:15 +0200 Subject: [PATCH] add tests for value_cast of quantity_point --- test/static/quantity_point_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/static/quantity_point_test.cpp b/test/static/quantity_point_test.cpp index 27016618..b186689c 100644 --- a/test/static/quantity_point_test.cpp +++ b/test/static/quantity_point_test.cpp @@ -1677,4 +1677,17 @@ static_assert(invalid_addition(5 * isq::activity[Bq], 10 / (2 * isq::time[s]), q static_assert(invalid_subtraction(quantity_point{5 * isq::activity[Bq]}, 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz])); +// value_cast + +static_assert(value_cast(quantity_point{2 * km}).quantity_from_zero().numerical_value_in(m) == 2000); +static_assert(value_cast(quantity_point{2000 * m}).quantity_from_zero().numerical_value_in(km) == 2); +static_assert(value_cast(quantity_point{1.23 * m}).quantity_from_zero().numerical_value_in(m) == 1); +static_assert( + value_cast(quantity_point{2000.0 * m / (3600.0 * s)}).quantity_from_zero().numerical_value_in(km / h) == 2); +// lvalue references in value_cast +namespace lvalue_tests { +constexpr quantity_point lvalue_qp{2 * km}; +static_assert(value_cast(lvalue_qp).quantity_from_zero().numerical_value_in(m) == 2000); +} // namespace lvalue_tests + } // namespace