From ee2abaf9f78e11d511a2b351ae2d2261a7eeaeec Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 13 Jun 2023 09:18:19 +0300 Subject: [PATCH] test: `pow` and `sqrt` checks added for fractional exponent quantity --- test/unit_test/static/fractional_exponent_quantity.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit_test/static/fractional_exponent_quantity.cpp b/test/unit_test/static/fractional_exponent_quantity.cpp index d971efde..5c5a0285 100644 --- a/test/unit_test/static/fractional_exponent_quantity.cpp +++ b/test/unit_test/static/fractional_exponent_quantity.cpp @@ -40,7 +40,13 @@ static_assert(power_spectral_density.dimension == pow<2>(amplitude_spectral_dens static_assert(sqrt(square(si::volt) / si::hertz) == si::volt / sqrt(si::hertz)); static_assert(square(si::volt) / si::hertz == pow<2>(si::volt / sqrt(si::hertz))); -// TODO Should there be `pow()` and `sqrt()` for references as well? How to compare the results? +constexpr auto sqrt_res = sqrt(power_spectral_density[square(si::volt) / si::hertz]); +static_assert(implicitly_convertible(get_quantity_spec(sqrt_res), amplitude_spectral_density)); +static_assert(get_unit(sqrt_res) == si::volt / sqrt(si::hertz)); + +constexpr auto pow_res = pow<2>(amplitude_spectral_density[si::volt / sqrt(si::hertz)]); +static_assert(implicitly_convertible(power_spectral_density, get_quantity_spec(pow_res))); +static_assert(square(si::volt) / si::hertz == get_unit(pow_res)); static_assert(sqrt(16 * power_spectral_density[square(si::volt) / si::hertz]) == 4 * amplitude_spectral_density[si::volt / sqrt(si::hertz)]);