test: a few more natural units tests added

This commit is contained in:
Mateusz Pusz
2024-11-29 11:11:13 +01:00
parent 9c4671790e
commit 52e95f9b2e
2 changed files with 19 additions and 0 deletions

View File

@ -50,6 +50,14 @@ inline constexpr struct my_relative_origin final : relative_point_origin<my_orig
inline constexpr auto dim_speed = isq::dim_length / isq::dim_time;
namespace nu {
inline constexpr struct second final : named_unit<"s"> {
} second;
inline constexpr struct hour final : named_unit<"h", mag<3600> * second> {
} hour;
} // namespace nu
// BaseDimension
static_assert(detail::BaseDimension<struct isq::dim_length>);
static_assert(!detail::BaseDimension<decltype(isq::dim_length / isq::dim_time)>);
@ -143,6 +151,8 @@ static_assert(Unit<struct si::standard_gravity>);
static_assert(Unit<scaled_unit<mag<10>, struct si::second>>);
static_assert(Unit<derived_unit<struct si::metre, per<struct si::second>>>);
static_assert(Unit<struct one>);
static_assert(Unit<struct nu::second>);
static_assert(Unit<decltype(si::metre / nu::second)>);
static_assert(!Unit<named_unit<"?", kind_of<isq::length>>>);
static_assert(!Unit<named_unit<"?">>);
static_assert(!Unit<named_unit<"?", si::metre / si::second>>);
@ -193,6 +203,9 @@ static_assert(AssociatedUnit<struct si::standard_gravity>);
static_assert(AssociatedUnit<scaled_unit<mag<10>, struct si::second>>);
static_assert(AssociatedUnit<derived_unit<struct si::metre, per<struct si::second>>>);
static_assert(AssociatedUnit<struct one>);
static_assert(AssociatedUnit<decltype(get_common_unit(si::kilo<si::metre> / si::hour, si::metre / si::second))>);
static_assert(!AssociatedUnit<decltype(si::metre / nu::second)>);
static_assert(!AssociatedUnit<decltype(get_common_unit(si::kilo<si::metre> / nu::hour, si::metre / nu::second))>);
static_assert(!AssociatedUnit<named_unit<"?", kind_of<isq::length>>>);
static_assert(!AssociatedUnit<named_unit<"?">>);
static_assert(!AssociatedUnit<named_unit<"?", si::metre / si::second>>);

View File

@ -235,6 +235,12 @@ static_assert(
quantity<reference<derived_quantity_spec<length_, mass_, per<time_>>, MP_UNITS_NONCONST_TYPE(si::kilo<gram>)>{},
int>>);
// Mixed-systems quantities
static_assert(
is_of_type<
42 * metre / nu::time[nu::second],
quantity<reference<derived_quantity_spec<length_, per<time_>>, derived_unit<metre_, per<nu::second_>>>{}, int>>);
template<auto dim, auto unit>
concept invalid_nu_unit = !requires { dim[unit]; };