diff --git a/test/unit_test/static/custom_rep_min_req_test.cpp b/test/unit_test/static/custom_rep_min_req_test.cpp index 8f7783b8..2f50c244 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -25,6 +25,7 @@ #include "units/physical/si/frequency.h" #include "units/physical/si/speed.h" #include +#include #include using namespace units; @@ -172,60 +173,60 @@ using namespace units::physical::si; // Quantity from Scalar // int <- int static_assert(length(expl_impl(1)).count() == 1); -// static_assert(length(impl_expl(1)).count() == 1); // should not compile (not convertible) +static_assert(!std::is_constructible_v, impl_expl>); static_assert(length(int(impl_expl(1))).count() == 1); -// static_assert(length>(1).count() == expl_impl{1}); // should not compile (not convertible) +static_assert(!std::is_constructible_v>, int>); static_assert(length>(expl_impl(1)).count() == expl_impl{1}); static_assert(length>(1).count() == impl_expl{1}); // double <- double static_assert(length(expl_impl(1.0)).count() == 1.0); -// static_assert(length(impl_expl(1.0)).count() == 1.0); // should not compile (not convertible) +static_assert(!std::is_constructible_v, impl_expl>); static_assert(length(double(impl_expl(1.0))).count() == 1.0); -// static_assert(length>(1.0).count() == expl_impl{1.0}); // should not compile (not convertible) +static_assert(!std::is_constructible_v>, double>); static_assert(length>(expl_impl(1.0)).count() == expl_impl{1.0}); static_assert(length>(1.0).count() == impl_expl{1.0}); // double <- int static_assert(length(expl_impl(1)).count() == 1.0); -// static_assert(length(impl_expl(1)).count() == 1.0); // should not compile (not convertible) +static_assert(!std::is_constructible_v, impl_expl>); static_assert(length(int(impl_expl(1))).count() == 1.0); -// static_assert(length>(1).count() == expl_impl{1}); // should not compile (not convertible) +static_assert(!std::is_constructible_v>, int>); static_assert(length>(expl_impl(1)).count() == expl_impl{1}); static_assert(length>(1).count() == impl_expl{1.0}); // int <- double -// static_assert(length(expl_impl(1.0)).count() == 1); // should not compile (truncating conversion) -// static_assert(length>(1.0).count() == impl_expl{1}); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v, expl_impl>); +static_assert(!std::is_constructible_v>, double>); // Quantity from other Quantity with different Rep // int <- int static_assert(length(length>(expl_impl(1))).count() == 1); -// static_assert(length(length>(1)).count() == 1); // should not compile (not convertible) +static_assert(!std::is_constructible_v, length>>); static_assert(length(quantity_cast(length>(1))).count() == 1); -// static_assert(length>(length(1)).count() == expl_impl{1}); // should not compile (not convertible) +static_assert(!std::is_constructible_v>, length>); static_assert(length>(quantity_cast>(length(1))).count() == expl_impl{1}); static_assert(length>(length(1)).count() == impl_expl{1}); // double <- double static_assert(length(length>(expl_impl(1.0))).count() == 1.0); -// static_assert(length(length>(1.0)).count() == 1.0); // should not compile (not convertible) +static_assert(!std::is_constructible_v, length>>); static_assert(length(quantity_cast(length>(1.0))).count() == 1.0); -// static_assert(length>(length(1.0).count() == expl_impl{1.0}); // should not compile (not convertible) +static_assert(!std::is_constructible_v>, length>); static_assert(length>(quantity_cast>(length(1.0))).count() == expl_impl{1.0}); static_assert(length>(length(1.0)).count() == impl_expl{1.0}); // double <- int static_assert(length(length>(expl_impl(1))).count() == 1.0); -// static_assert(length(length>(1)).count() == 1.0); // should not compile (not convertible) +static_assert(!std::is_constructible_v, length>>); static_assert(length(quantity_cast(length>(1))).count() == 1.0); -// static_assert(length>(length(1)).count() == expl_impl{1}); // should not compile (not convertible) +static_assert(!std::is_constructible_v>, length>); static_assert(length>(quantity_cast>(length(1))).count() == expl_impl{1}); static_assert(length>(length(1)).count() == impl_expl{1.0}); // int <- double -// static_assert(length(length>(1.0)).count() == 1); // should not compile (truncating conversion) -// static_assert(length>(length(1.0)).count() == impl_expl{1}); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v, length>>); +static_assert(!std::is_constructible_v>, length>); // unit conversions @@ -236,43 +237,43 @@ static_assert(length>(length>(1) static_assert(length>(length>(expl_impl(1))).count() == expl_impl(1000)); static_assert(length>(length>(expl_expl(1))).count() == expl_expl(1000)); -// static_assert(length>(length>(2000)).count() == impl(2)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, length>>); static_assert(length>(quantity_cast(length>(2000))).count() == impl(2)); -// static_assert(length>(length>(expl(2000))).count() == expl(2)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, length>>); static_assert(length>(quantity_cast(length>(expl(2000)))).count() == expl(2)); -// static_assert(length>(length>(2000)).count() == impl_impl(2)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, length>>); static_assert(length>(quantity_cast(length>(2000))).count() == impl_impl(2)); -// static_assert(length>(length>(2000)).count() == impl_expl(2)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, length>>); static_assert(length>(quantity_cast(length>(2000))).count() == impl_expl(2)); -// static_assert(length>(length>(expl_impl(2000))).count() == expl_impl(2)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, length>>); static_assert(length>(quantity_cast(length>(expl_impl(2000)))).count() == expl_impl(2)); -// static_assert(length>(length>(expl_expl(2000))).count() == expl_expl(2)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, length>>); static_assert(length>(quantity_cast(length>(expl_expl(2000)))).count() == expl_expl(2)); -// static_assert(speed>(speed>(72)).count() == impl(20)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(72))).count() == impl(20)); -// static_assert(speed>(speed>(expl(72))).count() == expl(20)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(expl(72)))).count() == expl(20)); -// static_assert(speed>(speed>(72)).count() == impl_impl(20)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(72))).count() == impl_impl(20)); -// static_assert(speed>(speed>(72)).count() == impl_expl(20)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(72))).count() == impl_expl(20)); -// static_assert(speed>(speed>(expl_impl(72))).count() == expl_impl(20)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(expl_impl(72)))).count() == expl_impl(20)); -// static_assert(speed>(speed>(expl_expl(72))).count() == expl_expl(20)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(expl_expl(72)))).count() == expl_expl(20)); -// static_assert(speed>(speed>(20)).count() == impl(72)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(20))).count() == impl(72)); -// static_assert(speed>(speed>(expl(20))).count() == expl(72)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(expl(20)))).count() == expl(72)); -// static_assert(speed>(speed>(20)).count() == impl_impl(72)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(20))).count() == impl_impl(72)); -// static_assert(speed>(speed>(20)).count() == impl_expl(72)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(20))).count() == impl_expl(72)); -// static_assert(speed>(speed>(expl_impl(20))).count() == expl_impl(72)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(expl_impl(20)))).count() == expl_impl(72)); -// static_assert(speed>(speed>(expl_expl(20))).count() == expl_expl(72)); // should not compile (truncating conversion) +static_assert(!std::is_constructible_v>, speed>>); static_assert(speed>(quantity_cast(speed>(expl_expl(20)))).count() == expl_expl(72)); } // namespace