diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index bdab9c76..e3cd3337 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -39,11 +39,8 @@ add_library( chrono_test.cpp concepts_test.cpp # custom_rep_test_min_expl.cpp - # dimension_op_test.cpp dimension_test.cpp - # dimensions_concepts_test.cpp fixed_string_test.cpp - # fps_test.cpp fractional_exponent_quantity.cpp hep_test.cpp iau_test.cpp @@ -61,8 +58,6 @@ add_library( quantity_spec_test.cpp ratio_test.cpp reference_test.cpp - # si_cgs_test.cpp - # si_fps_test.cpp # si_test.cpp symbol_text_test.cpp type_list_test.cpp diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp deleted file mode 100644 index 474249fb..00000000 --- a/test/unit_test/static/custom_unit_test.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include "test_tools.h" -#include -#include -#include -#include -#include -#include -#include // IWYU pragma: keep -#include - -namespace { - -using namespace units; -using namespace units::isq::si; - -// power spectral density -struct sq_volt_per_hertz : derived_unit {}; -struct dim_power_spectral_density : - derived_dimension, - units::exponent> {}; - -template U, Representation Rep = double> -using power_spectral_density = quantity; - -// amplitude spectral density -struct volt_per_sqrt_hertz : derived_unit {}; -struct dim_amplitude_spectral_density : - derived_dimension, - units::exponent> {}; - -template U, Representation Rep = double> -using amplitude_spectral_density = quantity; - -} // namespace - -namespace { - -static_assert(compare, dim_amplitude_spectral_density>); -static_assert(compare, dim_power_spectral_density>); - -static_assert(compare(amplitude_spectral_density(4))), - decltype(power_spectral_density(16))>); -static_assert(compare(16))), - decltype(amplitude_spectral_density(4))>); - -} // namespace - -namespace { - -struct kilogram_per_second : derived_unit {}; -struct dim_mass_rate : - derived_dimension, units::exponent> { -}; -struct kilogram_per_hour : derived_scaled_unit {}; -[[maybe_unused]] constexpr auto a = 1_q_kg / 1_q_h; - -} // namespace diff --git a/test/unit_test/static/dimension_op_test.cpp b/test/unit_test/static/dimension_op_test.cpp deleted file mode 100644 index fe1561cb..00000000 --- a/test/unit_test/static/dimension_op_test.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include -#include -#include -#include - -using namespace units; - -namespace { - -struct u0 : named_unit {}; -struct d0 : base_dimension<"d0", u0> {}; -struct u1 : named_unit {}; -struct d1 : base_dimension<"d1", u1> {}; -struct u2 : named_unit {}; -struct d2 : base_dimension<"d2", u2> {}; -struct u3 : named_unit {}; -struct d3 : base_dimension<"d3", u3> {}; - -// exponent_invert - -static_assert(is_same_v>, units::exponent>); -static_assert(is_same_v>, units::exponent>); - -// dim_unpack - -template -using dim_unpack = TYPENAME detail::dim_unpack::type; - -template -using derived_dim = detail::derived_dimension_base; - -static_assert(is_same_v, exponent_list<>>); -static_assert(is_same_v>, exponent_list>>); -static_assert(is_same_v, units::exponent>, - exponent_list, units::exponent>>); -using dim1 = derived_dim>; -using dim2 = derived_dim, units::exponent>; -static_assert(is_same_v, units::exponent>, - exponent_list, units::exponent>>); -static_assert(is_same_v, units::exponent, units::exponent>, - exponent_list, units::exponent, units::exponent, - units::exponent>>); - -// dim_invert -static_assert(is_same_v>>, d0>); -static_assert(is_same_v>>, unknown_dimension>>); -static_assert(is_same_v, units::exponent>>, - unknown_dimension, units::exponent>>); - -// make_dimension - -template -using make_dimension = detail::make_dimension; - -static_assert(is_same_v>, derived_dim>>); -static_assert(is_same_v, units::exponent>, - derived_dim, units::exponent>>); -static_assert(is_same_v, units::exponent>, - derived_dim, units::exponent>>); -static_assert( - is_same_v, units::exponent>, derived_dim>>); -static_assert( - is_same_v, units::exponent>, derived_dim>>); -static_assert( - is_same_v, units::exponent>, derived_dim>>); -static_assert( - is_same_v, units::exponent>, derived_dim>>); - -static_assert(is_same_v, units::exponent, units::exponent, - units::exponent>, - derived_dim, units::exponent>>); -static_assert(is_same_v, units::exponent, units::exponent, - units::exponent>, - derived_dim, units::exponent>>); - -static_assert(is_same_v, units::exponent, units::exponent>, - derived_dim>>); -static_assert(is_same_v, units::exponent, units::exponent>, - derived_dim>>); -static_assert(is_same_v, units::exponent, units::exponent>, - derived_dim>>); - -// dimension_multiply - -static_assert(is_same_v>, derived_dim>>, - unknown_dimension, units::exponent>>); -static_assert(is_same_v>, d1>, - unknown_dimension, units::exponent>>); -static_assert(is_same_v>>, - unknown_dimension, units::exponent>>); -static_assert(is_same_v, unknown_dimension, units::exponent>>); -static_assert( - is_same_v< - dimension_multiply, units::exponent, units::exponent>, - derived_dim>>, - unknown_dimension, units::exponent, units::exponent, units::exponent>>); -static_assert( - is_same_v, units::exponent, units::exponent>, - derived_dim>>, - unknown_dimension, units::exponent, units::exponent>>); -static_assert( - is_same_v, units::exponent, units::exponent>, - derived_dim>>, - unknown_dimension, units::exponent>>); -static_assert( - is_same_v>, derived_dim>>, d0>); - -// dimension_divide - -static_assert(is_same_v>, derived_dim>>, - unknown_dimension, units::exponent>>); -static_assert( - is_same_v>, unknown_dimension>>, d0>); - -} // namespace diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp deleted file mode 100644 index f96a11dc..00000000 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - - -#include - -namespace { - -using namespace units; -using namespace units::isq; - -static_assert(Length>); -static_assert(!Length>); - -static_assert(Mass>); -static_assert(!Mass>); - -static_assert(Time>); -static_assert(!Time>); - -static_assert(ElectricCurrent>); -static_assert(!ElectricCurrent>); - -static_assert(ThermodynamicTemperature>); -static_assert(!ThermodynamicTemperature>); - -static_assert(AmountOfSubstance>); -static_assert(!AmountOfSubstance>); - -static_assert(LuminousIntensity>); -static_assert(!LuminousIntensity>); - -static_assert(Frequency>); -static_assert(!Frequency>); - -static_assert(Area>); -static_assert(!Area>); - -static_assert(Volume>); -static_assert(!Volume>); -#if UNITS_DOWNCAST_MODE == 0 -static_assert( - Volume>, unknown_coherent_unit>>>); -#endif - -static_assert(Speed>); -static_assert(!Speed>); - -static_assert(Acceleration>); -static_assert(!Acceleration>); -#if UNITS_DOWNCAST_MODE == 0 -static_assert(Acceleration, exponent>, - unknown_coherent_unit, exponent>>>); -#endif - -static_assert(Force>); -static_assert(!Force>); -#if UNITS_DOWNCAST_MODE == 0 -// static_assert(Force, exponent, -// exponent>, unknown_coherent_unit, -// exponent>>); -#endif - -static_assert(Energy>); -static_assert(!Energy>); -#if UNITS_DOWNCAST_MODE == 0 -// static_assert(Energy, exponent, -// exponent>, unknown_coherent_unit, -// exponent>>); -#endif - -static_assert(Power>); -static_assert(!Power>); - -static_assert(Voltage>); -static_assert(!Voltage>); - -static_assert(ElectricCharge>); -static_assert(!ElectricCharge>); - -static_assert(Capacitance>); -static_assert(!Capacitance>); - -static_assert(SurfaceTension>); -static_assert(!SurfaceTension>); - -static_assert(Pressure>); -static_assert(!Pressure>); - -static_assert(MagneticInduction>); -static_assert(!MagneticInduction>); - -static_assert(MagneticFlux>); -static_assert(!MagneticFlux>); - -static_assert(Inductance>); -static_assert(!Inductance>); - -static_assert(Conductance>); -static_assert(!Conductance>); - -// TODO Add when downcasting issue is solved -// static_assert(Radioactivity>); -// static_assert(!Radioactivity>); - -static_assert(CatalyticActivity>); -static_assert(!CatalyticActivity>); - -static_assert(AbsorbedDose>); -static_assert(!AbsorbedDose>); - -static_assert(CurrentDensity>); -static_assert(!CurrentDensity>); - -static_assert(Concentration>); -static_assert(!Concentration>); - -static_assert(Luminance>); -static_assert(!Luminance>); - -static_assert(DynamicViscosity>); -static_assert(!DynamicViscosity>); - -static_assert(HeatCapacity>); -static_assert(!HeatCapacity>); - -static_assert(SpecificHeatCapacity>); -static_assert(!SpecificHeatCapacity>); - -static_assert(MolarHeatCapacity>); -static_assert(!MolarHeatCapacity>); - -static_assert(ThermalConductivity>); -static_assert(!ThermalConductivity>); - -// TODO Add when downcasting issue is solved -// static_assert(EnergyDensity>); -// static_assert(!EnergyDensity>); - -static_assert(ElectricFieldStrength>); -static_assert(!ElectricFieldStrength>); - -static_assert(ChargeDensity>); -static_assert(!ChargeDensity>); - -static_assert(SurfaceChargeDensity>); -static_assert(!SurfaceChargeDensity>); - -static_assert(Permittivity>); -static_assert(!Permittivity>); - -static_assert(Permeability>); -static_assert(!Permeability>); - -static_assert(MolarEnergy>); -static_assert(!MolarEnergy>); - -} // namespace diff --git a/test/unit_test/static/fps_test.cpp b/test/unit_test/static/fps_test.cpp deleted file mode 100644 index b0ca5d71..00000000 --- a/test/unit_test/static/fps_test.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include -#include -#include -#include - -namespace { - -using namespace units; -using namespace units::isq::si::fps; - -/* ************** BASE DIMENSIONS **************** */ - -// length - -static_assert(foot::symbol == "ft"); - -// mass - -// time - -/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ - -// speed - -static_assert(10_q_ft / 5_q_s == 2_q_ft_per_s); -static_assert(10_q_ft / 2_q_ft_per_s == 5_q_s); -static_assert(10_q_ft == 2_q_ft_per_s * 5_q_s); - -static_assert(detail::unit_text() == "ft/s"); - -// area -static_assert(as_ratio(foot::mag / dimension_unit::mag) == ratio(1)); - -static_assert(1_q_ft * 1_q_ft == 1_q_ft2); -static_assert(100_q_ft2 / 10_q_ft == 10_q_ft); - -static_assert(detail::unit_text() == basic_symbol_text("ft²", "ft^2")); - -// volume -static_assert(1_q_yd * 1_q_yd * 1_q_yd == 1_q_yd3); -static_assert(as_ratio(cubic_yard::mag / cubic_foot::mag) == ratio(27)); - -/* ************** DERIVED DIMENSIONS WITH NAMED UNITS **************** */ - -// acceleration - -static_assert(10_q_ft_per_s / 10_q_s == 1_q_ft_per_s2); -static_assert(10_q_ft_per_s / 1_q_ft_per_s2 == 10_q_s); -static_assert(1_q_ft_per_s2 * 10_q_s == 10_q_ft_per_s); - -// force - -static_assert(10_q_lb * 10_q_ft_per_s2 == 100_q_pdl); -static_assert(100_q_pdl / 10_q_lb == 10_q_ft_per_s2); -static_assert(100_q_pdl / 10_q_ft_per_s2 == 10_q_lb); - -// pressure -static_assert(10_q_pdl / 10_q_ft2 == 1_q_pdl_per_ft2); -static_assert(10_q_pdl / 1_q_pdl_per_ft2 == 10_q_ft2); -static_assert(1_q_pdl_per_ft2 * 10_q_ft2 == 10_q_pdl); - -// energy - -static_assert(10_q_pdl * 10_q_ft == 100_q_ft_pdl); -static_assert(100_q_ft_pdl / 10_q_ft == 10_q_pdl); -static_assert(100_q_ft_pdl / 10_q_pdl == 10_q_ft); - -static_assert(detail::unit_text() == basic_symbol_text("ft⋅pdl", "ft pdl")); -static_assert(detail::unit_text() == basic_symbol_text("ft⋅lbf", "ft lbf")); - -/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */ - -// power - -static_assert(10_q_ft_pdl / 10_q_s == 1_q_ft_pdl_per_s); -static_assert(1_q_ft_pdl_per_s * 10_q_s == 10_q_ft_pdl); -static_assert(10_q_ft_pdl / 1_q_ft_pdl_per_s == 10_q_s); - -static_assert(detail::unit_text() == basic_symbol_text("ft⋅pdl/s", "ft pdl/s")); -static_assert(detail::unit_text() == basic_symbol_text("ft⋅lbf/s", "ft lbf/s")); - -} // namespace diff --git a/test/unit_test/static/si_cgs_test.cpp b/test/unit_test/static/si_cgs_test.cpp deleted file mode 100644 index d502cffe..00000000 --- a/test/unit_test/static/si_cgs_test.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include // IWYU pragma: keep -#include -#include -#include -#include // IWYU pragma: keep -#include -#include -#include -#include -#include // IWYU pragma: keep - -namespace { - -using namespace units::isq; - -template -inline constexpr units::ratio quantity_ratio = units::as_ratio(units::detail::quantity_magnitude); - -static_assert(quantity_ratio> == units::ratio(1)); -static_assert(quantity_ratio> == units::ratio(1, 100)); -static_assert(quantity_ratio> == units::ratio(1)); -static_assert(quantity_ratio> == units::ratio(1, 100)); -static_assert(quantity_ratio> == - units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram -static_assert(quantity_ratio> == - units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here - -static_assert(si::cgs::length(100) == si::length(1)); -static_assert(si::cgs::mass(1'000) == si::mass(1)); -static_assert(si::cgs::time(1) == si::time(1)); -static_assert(si::cgs::speed(100) == si::speed(1)); -static_assert(si::cgs::area(10000) == si::area(1)); -static_assert(si::cgs::acceleration(100) == si::acceleration(1)); -static_assert(si::cgs::force(100'000) == si::force(1)); -static_assert(si::cgs::energy(10'000'000) == si::energy(1)); -static_assert(si::cgs::power(10'000'000) == si::power(1)); -static_assert(si::cgs::pressure(10) == si::pressure(1)); - -namespace si_test { - -using namespace units::isq::si::literals; - -static_assert(si::cgs::length(100) == 1_q_m); -static_assert(si::cgs::mass(1'000) == 1_q_kg); -static_assert(si::cgs::time(1) == 1_q_s); -static_assert(si::cgs::speed(100) == 1_q_m_per_s); -static_assert(si::cgs::acceleration(100) == 1_q_m_per_s2); -static_assert(si::cgs::force(100'000) == 1_q_N); -static_assert(si::cgs::energy(10'000'000) == 1_q_J); -static_assert(si::cgs::power(10'000'000) == 1_q_W); -static_assert(si::cgs::pressure(10) == 1_q_Pa); - -} // namespace si_test - -namespace cgs_test { - -using namespace units::isq::si::cgs::literals; - -static_assert(100_q_cm == si::length(1)); -static_assert(1'000_q_g == si::mass(1)); -static_assert(1_q_s == si::time(1)); -static_assert(100_q_cm_per_s == si::speed(1)); -static_assert(100_q_Gal == si::acceleration(1)); -static_assert(100'000_q_dyn == si::force(1)); -static_assert(10'000'000_q_erg == si::energy(1)); -static_assert(10'000'000_q_erg_per_s == si::power(1)); -static_assert(10_q_Ba == si::pressure(1)); - -} // namespace cgs_test - -namespace both_test { - -using namespace units::isq::si::literals; -using namespace units::isq::si::cgs::literals; - -// static_assert(100_q_cm == 1_q_m); // ambiguous -// static_assert(1'000_q_g == 1_q_kg); // ambiguous -static_assert(1_q_s == 1_q_s); -static_assert(100_q_cm_per_s == 1_q_m_per_s); -static_assert(100_q_Gal == 1_q_m_per_s2); -static_assert(100'000_q_dyn == 1_q_N); -static_assert(10'000'000_q_erg == 1_q_J); -static_assert(10'000'000_q_erg_per_s == 1_q_W); -static_assert(10_q_Ba == quantity_cast(1_q_Pa)); - -} // namespace both_test - -namespace cgs_test { - -// addition - -static_assert(100_q_cm + si::length(1) == si::length(2)); -static_assert(si::length(1) + 100_q_cm == si::length(2)); -static_assert(quantity_cast>(100_q_cm) + si::length(1) == si::length(2)); -static_assert(si::length(1) + quantity_cast>(100_q_cm) == si::length(2)); -static_assert(100_q_cm + quantity_cast>(si::length(1)) == 200_q_cm); -static_assert(quantity_cast>(si::length(1)) + 100_q_cm == 200_q_cm); - -// subtraction - -static_assert(500_q_cm - si::length(1) == si::length(4)); -static_assert(si::length(5) - 100_q_cm == si::length(4)); -static_assert(quantity_cast>(500_q_cm) - si::length(1) == si::length(4)); -static_assert(si::length(5) - quantity_cast>(100_q_cm) == si::length(4)); -static_assert(500_q_cm - quantity_cast>(si::length(1)) == 400_q_cm); -static_assert(quantity_cast>(si::length(5)) - 100_q_cm == 400_q_cm); - -// multiplication - -// TODO Add support for comparing of an unknown_dimension -// static_assert(200._q_cm * si::length(2) == si::area(4)); - -static_assert(quantity_cast(200._q_cm) * si::length(2) == si::area(4)); -static_assert(200._q_cm * quantity_cast(si::length(2)) == 40'000_q_cm2); - -// TODO Add support for quantity_cast on an unknown_dimension? -// static_assert(quantity_cast>(200_q_cm * si::length(2)) == -// si::area(4)); static_assert(quantity_cast(200_q_cm * si::length(2)) == -// si::area(4)); static_assert(quantity_cast>(200_q_cm * -// si::length(2)) == 40'000_q_cm2); static_assert(quantity_cast(200_q_cm * -// si::length(2)) == 40'000_q_cm2); - -// division - -// TODO Add support for comparing of an unknown_dimension -// static_assert(si::area(4) / 200_q_cm == si::length(2)); -// static_assert(400._q_cm / si::length(2) == 2); - -static_assert(si::area(4) / quantity_cast>(200_q_cm) == - si::length(2)); -static_assert(quantity_cast>(si::area(4)) / 200._q_cm == - 200_q_cm); - -static_assert(si::cgs::length(50) == si::length(50)); -static_assert(si::cgs::mass(50) == si::mass(50)); - -static_assert(1 / si::cgs::length(50) == 1 / si::length(50)); -static_assert(1 / si::cgs::length(50) == 1 / si::length(50)); - -static_assert(1 / si::cgs::mass(50) == 1 / si::mass(50)); -static_assert(1 / si::cgs::mass(50) == 1 / si::mass(50)); - -static_assert(si::cgs::length(50) * si::cgs::mass(50) == - si::length(50) * si::mass(50)); -static_assert(si::cgs::length(50) * si::cgs::mass(50) == - si::length(50) * si::mass(50)); - -static_assert(si::cgs::length(50) / si::cgs::mass(50) == - si::length(50) / si::mass(50)); - -} // namespace cgs_test - -} // namespace diff --git a/test/unit_test/static/si_fps_test.cpp b/test/unit_test/static/si_fps_test.cpp deleted file mode 100644 index 0f630fa3..00000000 --- a/test/unit_test/static/si_fps_test.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - -using namespace units::isq; - -static_assert(si::fps::length(1) == si::length(0.3048)); -static_assert(si::fps::mass(1) == si::mass(0.45359237)); -static_assert(si::fps::time(1) == si::time(1)); -static_assert(si::fps::speed(1) == si::speed(0.3048)); -static_assert(si::fps::area(1) == si::area(0.09290304)); -static_assert(si::fps::acceleration(1) == - si::acceleration(0.3048)); -static_assert(si::fps::force(1) > si::force(0.138254) && - si::fps::force(1) < si::force(0.138256)); -static_assert(si::fps::energy(1) > si::energy(0.042140110093804) && - si::fps::energy(1) < si::energy(0.042140110093806)); -static_assert(si::fps::power(1) > si::power(0.042140110093804) && - si::fps::power(1) < si::power(0.042140110093806)); -static_assert(si::fps::pressure(1) > si::pressure(1.4881639435) && - si::fps::pressure(1) < si::pressure(1.4881639437)); - -namespace si_literals { - -using namespace units::isq::si::literals; - -static_assert(si::fps::length(1) == 0.3048_q_m); -static_assert(si::fps::mass(1) == 0.45359237_q_kg); -static_assert(si::fps::time(1) == 1_q_s); -static_assert(si::fps::speed(1) == 0.3048_q_m_per_s); -static_assert(si::fps::area(1) == 0.09290304_q_m2); -static_assert(si::fps::acceleration(1) == 0.3048_q_m_per_s2); -static_assert(si::fps::force(1) > 0.138254_q_N && si::fps::force(1) < 0.138256_q_N); -static_assert(si::fps::energy(1) > 0.042140110093804_q_J && - si::fps::energy(1) < 0.042140110093806_q_J); -static_assert(si::fps::power(1) > 0.042140110093804_q_W && - si::fps::power(1) < 0.042140110093806_q_W); -static_assert(si::fps::pressure(1) > 1.4881639435_q_Pa && - si::fps::pressure(1) < 1.4881639437_q_Pa); -} // namespace si_literals - -namespace fps_literals { - -using namespace units::isq::si::fps::literals; -using namespace units::isq::si::fps::references; - -static_assert(1 * ft == si::length(0.3048)); -static_assert(1_q_lb == si::mass(0.45359237)); -static_assert(1_q_s == si::time(1)); -static_assert(1_q_ft_per_s == si::speed(0.3048)); -static_assert(1_q_ft2 == si::area(0.09290304)); -static_assert(1_q_ft_per_s2 == si::acceleration(0.3048)); -static_assert(1_q_pdl > si::force(0.138254) && 1_q_pdl < si::force(0.138256)); -static_assert(1_q_ft_pdl > si::energy(0.042140110093804) && - 1_q_ft_pdl < si::energy(0.042140110093806)); -static_assert(1_q_ft_pdl_per_s > si::power(0.042140110093804) && - 1_q_ft_pdl_per_s < si::power(0.042140110093806)); -static_assert(1_q_pdl_per_ft2 > si::pressure(1.4881639435) && - 1_q_pdl_per_ft2 < si::pressure(1.4881639437)); -} // namespace fps_literals - -namespace fps_plus_si_literals { - -using namespace units::isq::si::literals; -using namespace units::isq::si::fps::literals; -using namespace units::isq::si::fps::references; - -// static_assert(100_q_cm == 1_q_m); // ambiguous -// static_assert(1'000_q_g == 1_q_kg); // ambiguous -static_assert(1 * ft == 0.3048_q_m); -static_assert(1_q_lb == 0.45359237_q_kg); -static_assert(1_q_s == 1_q_s); -static_assert(1_q_ft_per_s == 0.3048_q_m_per_s); -static_assert(1_q_ft2 == 0.09290304_q_m2); -static_assert(1_q_ft_per_s2 == 0.3048_q_m_per_s2); -static_assert(1_q_pdl > 0.138254_q_N && 1_q_pdl < 0.138256_q_N); -static_assert(1_q_ft_pdl > 0.042140110093804_q_J && 1_q_ft_pdl < 0.042140110093806_q_J); -static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W && 1_q_ft_pdl_per_s < 0.042140110093806_q_W); -static_assert(1_q_pdl_per_ft2 > 1.4881639435_q_Pa && 1_q_pdl_per_ft2 < 1.4881639437_q_Pa); - -} // namespace fps_plus_si_literals - -namespace fps_test { -namespace { -constexpr bool is_near(auto a, auto b, auto tol) -{ - const auto diff = a - b; - return (diff <= tol) && (-diff <= tol); -} -} // namespace - -using namespace units::isq::si::fps::literals; -using namespace units::isq::si::fps::references; - -// addition - -static_assert(si::length(1) + 1 * ft == si::length(1.3048)); -static_assert(1 * ft + si::length(1) == si::length(1.3048)); -static_assert(is_near(quantity_cast>(1. * ft / 0.3048) + si::length(1), - si::length(2), - si::length(1))); // 1 m in ft + 1 m -static_assert(is_near(si::length(1) + quantity_cast>(1. * ft / 0.3048), - si::length(2), - si::length(1))); // 1 m + 1 m in ft -static_assert(1 * ft + quantity_cast>(si::length(0.3048)) == - 2 * ft); // 1 ft + 1 ft in m -static_assert(quantity_cast>(si::length(0.3048)) + 1 * ft == - 2 * ft); // 1 ft in m + 1 ft - -// substraction - -static_assert(1 * ft - si::length(1) == -si::length(0.6952)); -static_assert(si::length(1) - 1 * ft == si::length(0.6952)); -static_assert(quantity_cast>(6. * ft) - si::length(1) > - si::length(0.8287) && - quantity_cast>(6. * ft) - si::length(1) < - si::length(0.8289)); // 6 ft in m - 1 m = ... m -static_assert(si::length(5) - quantity_cast>(6 * ft) == - si::length(3.1712)); // 5 m - 6 ft in m = ... -static_assert(6. * ft - quantity_cast>(si::length(0.3048)) == - 5. * ft); // 6 ft - 1 ft in m = 5 ft -static_assert(quantity_cast>(si::length(1.8288)) - 1. * ft == - 5. * ft); // 6 ft in m - 1 ft = 5 ft - -// multiplication - -// TODO Add support for comparing of an unknown_dimension -// static_assert(2 * ft * si::length(2) == si::area(1.2192)); -static_assert(quantity_cast>(2. * ft) * si::length(2) == - si::area(1.2192)); -static_assert(quantity_cast>(2. * ft) * si::length(0.6096) == - si::area(0.371612160)); // 2 ft * 2 ft == 4 sq ft -static_assert(2. * ft * quantity_cast>(si::length(0.6096)) == 4._q_ft2); - -// division - -// TODO Add support for comparing of an unknown_dimension -// static_assert(si::area(4) / 200_q_cm == si::length(2)); -// static_assert(400._q_cm / si::length(2) == 2); - -static_assert(si::area(1.48644864) / quantity_cast>(4 * ft) == - si::length(1.2192)); // 16 ft2 / 4 ft = 4 ft -static_assert(quantity_cast>(si::area(1.48644864)) / (4. * ft) == - 4. * ft); // 16 ft2 / 4 ft = 4 ft - -} // namespace fps_test - -} // namespace