From 52e95f9b2e31006cfe0d34fff3cadee996b5c2ed Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 29 Nov 2024 11:11:13 +0100 Subject: [PATCH] test: a few more natural units tests added --- test/static/concepts_test.cpp | 13 +++++++++++++ test/static/reference_test.cpp | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/test/static/concepts_test.cpp b/test/static/concepts_test.cpp index 2ee71fbd6..44102368b 100644 --- a/test/static/concepts_test.cpp +++ b/test/static/concepts_test.cpp @@ -50,6 +50,14 @@ inline constexpr struct my_relative_origin final : relative_point_origin { +} second; +inline constexpr struct hour final : named_unit<"h", mag<3600> * second> { +} hour; + +} // namespace nu + // BaseDimension static_assert(detail::BaseDimension); static_assert(!detail::BaseDimension); @@ -143,6 +151,8 @@ static_assert(Unit); static_assert(Unit, struct si::second>>); static_assert(Unit>>); static_assert(Unit); +static_assert(Unit); +static_assert(Unit); static_assert(!Unit>>); static_assert(!Unit>); static_assert(!Unit>); @@ -193,6 +203,9 @@ static_assert(AssociatedUnit); static_assert(AssociatedUnit, struct si::second>>); static_assert(AssociatedUnit>>); static_assert(AssociatedUnit); +static_assert(AssociatedUnit / si::hour, si::metre / si::second))>); +static_assert(!AssociatedUnit); +static_assert(!AssociatedUnit / nu::hour, si::metre / nu::second))>); static_assert(!AssociatedUnit>>); static_assert(!AssociatedUnit>); static_assert(!AssociatedUnit>); diff --git a/test/static/reference_test.cpp b/test/static/reference_test.cpp index 4d6e1cfd7..fe8560026 100644 --- a/test/static/reference_test.cpp +++ b/test/static/reference_test.cpp @@ -235,6 +235,12 @@ static_assert( quantity>, MP_UNITS_NONCONST_TYPE(si::kilo)>{}, int>>); +// Mixed-systems quantities +static_assert( + is_of_type< + 42 * metre / nu::time[nu::second], + quantity>, derived_unit>>{}, int>>); + template concept invalid_nu_unit = !requires { dim[unit]; };