mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
test: no longer needed test suites removed
This commit is contained in:
@@ -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
|
||||
|
@@ -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 <units/bits/dimension_op.h>
|
||||
#include <units/derived_dimension.h>
|
||||
#include <units/isq/si/frequency.h>
|
||||
#include <units/isq/si/mass.h>
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/isq/si/voltage.h>
|
||||
#include <units/math.h> // IWYU pragma: keep
|
||||
#include <units/unit.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::isq::si;
|
||||
|
||||
// power spectral density
|
||||
struct sq_volt_per_hertz : derived_unit<sq_volt_per_hertz> {};
|
||||
struct dim_power_spectral_density :
|
||||
derived_dimension<dim_power_spectral_density, sq_volt_per_hertz, units::exponent<dim_voltage, 2>,
|
||||
units::exponent<dim_frequency, -1>> {};
|
||||
|
||||
template<UnitOf<dim_power_spectral_density> U, Representation Rep = double>
|
||||
using power_spectral_density = quantity<dim_power_spectral_density, U, Rep>;
|
||||
|
||||
// amplitude spectral density
|
||||
struct volt_per_sqrt_hertz : derived_unit<volt_per_sqrt_hertz> {};
|
||||
struct dim_amplitude_spectral_density :
|
||||
derived_dimension<dim_amplitude_spectral_density, volt_per_sqrt_hertz, units::exponent<dim_voltage, 1>,
|
||||
units::exponent<dim_frequency, -1, 2>> {};
|
||||
|
||||
template<UnitOf<dim_amplitude_spectral_density> U, Representation Rep = double>
|
||||
using amplitude_spectral_density = quantity<dim_amplitude_spectral_density, U, Rep>;
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
static_assert(compare<dimension_sqrt<dim_power_spectral_density>, dim_amplitude_spectral_density>);
|
||||
static_assert(compare<dimension_pow<dim_amplitude_spectral_density, 2>, dim_power_spectral_density>);
|
||||
|
||||
static_assert(compare<decltype(pow<2>(amplitude_spectral_density<volt_per_sqrt_hertz>(4))),
|
||||
decltype(power_spectral_density<sq_volt_per_hertz>(16))>);
|
||||
static_assert(compare<decltype(sqrt(power_spectral_density<sq_volt_per_hertz>(16))),
|
||||
decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
struct kilogram_per_second : derived_unit<kilogram_per_second> {};
|
||||
struct dim_mass_rate :
|
||||
derived_dimension<dim_mass_rate, kilogram_per_second, units::exponent<dim_mass, 1>, units::exponent<dim_time, -1>> {
|
||||
};
|
||||
struct kilogram_per_hour : derived_scaled_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
|
||||
[[maybe_unused]] constexpr auto a = 1_q_kg / 1_q_h;
|
||||
|
||||
} // namespace
|
@@ -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 <units/base_dimension.h>
|
||||
#include <units/bits/dim_unpack.h>
|
||||
#include <units/bits/dimension_op.h>
|
||||
#include <units/derived_dimension.h>
|
||||
#include <units/unit.h>
|
||||
|
||||
using namespace units;
|
||||
|
||||
namespace {
|
||||
|
||||
struct u0 : named_unit<u0, "u0"> {};
|
||||
struct d0 : base_dimension<"d0", u0> {};
|
||||
struct u1 : named_unit<u1, "u1"> {};
|
||||
struct d1 : base_dimension<"d1", u1> {};
|
||||
struct u2 : named_unit<u2, "u2"> {};
|
||||
struct d2 : base_dimension<"d2", u2> {};
|
||||
struct u3 : named_unit<u3, "u3"> {};
|
||||
struct d3 : base_dimension<"d3", u3> {};
|
||||
|
||||
// exponent_invert
|
||||
|
||||
static_assert(is_same_v<exponent_invert<units::exponent<d0, 2>>, units::exponent<d0, -2>>);
|
||||
static_assert(is_same_v<exponent_invert<units::exponent<d1, -2>>, units::exponent<d1, 2>>);
|
||||
|
||||
// dim_unpack
|
||||
|
||||
template<typename... Ts>
|
||||
using dim_unpack = TYPENAME detail::dim_unpack<Ts...>::type;
|
||||
|
||||
template<Exponent... Es>
|
||||
using derived_dim = detail::derived_dimension_base<Es...>;
|
||||
|
||||
static_assert(is_same_v<dim_unpack<>, exponent_list<>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<d0, 1>>, exponent_list<units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<d0, 1>, units::exponent<d1, 2>>,
|
||||
exponent_list<units::exponent<d0, 1>, units::exponent<d1, 2>>>);
|
||||
using dim1 = derived_dim<units::exponent<d0, 1>>;
|
||||
using dim2 = derived_dim<units::exponent<d0, 1>, units::exponent<d1, 2>>;
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<dim1, 2>, units::exponent<d0, 1>>,
|
||||
exponent_list<units::exponent<d0, 2>, units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<dim2, -2>, units::exponent<d0, 1>, units::exponent<d1, 2>>,
|
||||
exponent_list<units::exponent<d0, -2>, units::exponent<d1, -4>, units::exponent<d0, 1>,
|
||||
units::exponent<d1, 2>>>);
|
||||
|
||||
// dim_invert
|
||||
static_assert(is_same_v<dim_invert<derived_dim<units::exponent<d0, -1>>>, d0>);
|
||||
static_assert(is_same_v<dim_invert<derived_dim<units::exponent<d0, -2>>>, unknown_dimension<units::exponent<d0, 2>>>);
|
||||
static_assert(is_same_v<dim_invert<derived_dim<units::exponent<d0, 2>, units::exponent<d1, -1>>>,
|
||||
unknown_dimension<units::exponent<d0, -2>, units::exponent<d1, 1>>>);
|
||||
|
||||
// make_dimension
|
||||
|
||||
template<typename... Ts>
|
||||
using make_dimension = detail::make_dimension<Ts...>;
|
||||
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, 1>>, derived_dim<units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>>,
|
||||
derived_dim<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d1, 1>, units::exponent<d0, 1>>,
|
||||
derived_dim<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<make_dimension<units::exponent<d1, 1>, units::exponent<d1, 1>>, derived_dim<units::exponent<d1, 2>>>);
|
||||
static_assert(
|
||||
is_same_v<make_dimension<units::exponent<d1, 1>, units::exponent<d1, 1, 2>>, derived_dim<units::exponent<d1, 3, 2>>>);
|
||||
static_assert(
|
||||
is_same_v<make_dimension<units::exponent<d1, 1, 2>, units::exponent<d1, 1, 2>>, derived_dim<units::exponent<d1, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<make_dimension<units::exponent<d1, 2>, units::exponent<d1, 1, 2>>, derived_dim<units::exponent<d1, 5, 2>>>);
|
||||
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d0, 1>,
|
||||
units::exponent<d1, 1>>,
|
||||
derived_dim<units::exponent<d0, 2>, units::exponent<d1, 2>>>);
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, -1>, units::exponent<d1, -1>, units::exponent<d0, -1>,
|
||||
units::exponent<d1, -1>>,
|
||||
derived_dim<units::exponent<d0, -2>, units::exponent<d1, -2>>>);
|
||||
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d1, -1>>,
|
||||
derived_dim<units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, 1>, units::exponent<d0, -1>, units::exponent<d1, 1>>,
|
||||
derived_dim<units::exponent<d1, 1>>>);
|
||||
static_assert(is_same_v<make_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d0, -1>>,
|
||||
derived_dim<units::exponent<d1, 1>>>);
|
||||
|
||||
// dimension_multiply
|
||||
|
||||
static_assert(is_same_v<dimension_multiply<derived_dim<units::exponent<d0, 1>>, derived_dim<units::exponent<d1, 1>>>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(is_same_v<dimension_multiply<derived_dim<units::exponent<d0, 1>>, d1>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(is_same_v<dimension_multiply<d0, derived_dim<units::exponent<d1, 1>>>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(is_same_v<dimension_multiply<d0, d1>, unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<
|
||||
dimension_multiply<derived_dim<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d2, 1>>,
|
||||
derived_dim<units::exponent<d3, 1>>>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d2, 1>, units::exponent<d3, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<dimension_multiply<derived_dim<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d2, 1>>,
|
||||
derived_dim<units::exponent<d1, 1>>>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, 2>, units::exponent<d2, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<dimension_multiply<derived_dim<units::exponent<d0, 1>, units::exponent<d1, 1>, units::exponent<d2, 1>>,
|
||||
derived_dim<units::exponent<d1, -1>>>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d2, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<dimension_multiply<derived_dim<units::exponent<d0, 2>>, derived_dim<units::exponent<d0, -1>>>, d0>);
|
||||
|
||||
// dimension_divide
|
||||
|
||||
static_assert(is_same_v<dimension_divide<derived_dim<units::exponent<d0, 1>>, derived_dim<units::exponent<d1, 1>>>,
|
||||
unknown_dimension<units::exponent<d0, 1>, units::exponent<d1, -1>>>);
|
||||
static_assert(
|
||||
is_same_v<dimension_divide<derived_dim<units::exponent<d0, 2>>, unknown_dimension<units::exponent<d0, 1>>>, d0>);
|
||||
|
||||
} // namespace
|
@@ -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 <units/isq/si/si.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::isq;
|
||||
|
||||
static_assert(Length<si::length<si::metre>>);
|
||||
static_assert(!Length<si::time<si::second>>);
|
||||
|
||||
static_assert(Mass<si::mass<si::kilogram>>);
|
||||
static_assert(!Mass<si::time<si::second>>);
|
||||
|
||||
static_assert(Time<si::time<si::second>>);
|
||||
static_assert(!Time<si::length<si::metre>>);
|
||||
|
||||
static_assert(ElectricCurrent<si::electric_current<si::ampere>>);
|
||||
static_assert(!ElectricCurrent<si::time<si::second>>);
|
||||
|
||||
static_assert(ThermodynamicTemperature<si::thermodynamic_temperature<si::kelvin>>);
|
||||
static_assert(!ThermodynamicTemperature<si::time<si::second>>);
|
||||
|
||||
static_assert(AmountOfSubstance<si::amount_of_substance<si::mole>>);
|
||||
static_assert(!AmountOfSubstance<si::time<si::second>>);
|
||||
|
||||
static_assert(LuminousIntensity<si::luminous_intensity<si::candela>>);
|
||||
static_assert(!LuminousIntensity<si::time<si::second>>);
|
||||
|
||||
static_assert(Frequency<si::frequency<si::hertz>>);
|
||||
static_assert(!Frequency<si::time<si::second>>);
|
||||
|
||||
static_assert(Area<si::area<si::square_metre>>);
|
||||
static_assert(!Area<si::time<si::second>>);
|
||||
|
||||
static_assert(Volume<si::volume<si::cubic_metre>>);
|
||||
static_assert(!Volume<si::area<si::square_metre>>);
|
||||
#if UNITS_DOWNCAST_MODE == 0
|
||||
static_assert(
|
||||
Volume<quantity<unknown_dimension<exponent<si::dim_length, 3>>, unknown_coherent_unit<exponent<si::dim_length, 3>>>>);
|
||||
#endif
|
||||
|
||||
static_assert(Speed<si::speed<si::metre_per_second>>);
|
||||
static_assert(!Speed<si::time<si::second>>);
|
||||
|
||||
static_assert(Acceleration<si::acceleration<si::metre_per_second_sq>>);
|
||||
static_assert(!Acceleration<si::time<si::second>>);
|
||||
#if UNITS_DOWNCAST_MODE == 0
|
||||
static_assert(Acceleration<quantity<unknown_dimension<exponent<si::dim_length, 1>, exponent<si::dim_time, -2>>,
|
||||
unknown_coherent_unit<exponent<si::dim_length, 1>, exponent<si::dim_time, -2>>>>);
|
||||
#endif
|
||||
|
||||
static_assert(Force<si::force<si::newton>>);
|
||||
static_assert(!Force<si::time<si::second>>);
|
||||
#if UNITS_DOWNCAST_MODE == 0
|
||||
// static_assert(Force<quantity<unknown_dimension<exponent<si::dim_length, 1>, exponent<si::dim_time, -2>,
|
||||
// exponent<si::dim_mass, 1>>, unknown_coherent_unit<exponent<si::dim_length, 1>,
|
||||
// exponent<si::dim_time, -2>>>);
|
||||
#endif
|
||||
|
||||
static_assert(Energy<si::energy<si::joule>>);
|
||||
static_assert(!Energy<si::time<si::second>>);
|
||||
#if UNITS_DOWNCAST_MODE == 0
|
||||
// static_assert(Energy<quantity<unknown_dimension<exponent<si::dim_mass, 1>, exponent<si::dim_length, 2>,
|
||||
// exponent<si::dim_time, -3>>, unknown_coherent_unit<exponent<si::dim_mass, 1>,
|
||||
// exponent<si::dim_length, 2>>>);
|
||||
#endif
|
||||
|
||||
static_assert(Power<si::power<si::watt>>);
|
||||
static_assert(!Power<si::time<si::second>>);
|
||||
|
||||
static_assert(Voltage<si::voltage<si::volt>>);
|
||||
static_assert(!Voltage<si::time<si::second>>);
|
||||
|
||||
static_assert(ElectricCharge<si::electric_charge<si::coulomb>>);
|
||||
static_assert(!ElectricCharge<si::time<si::second>>);
|
||||
|
||||
static_assert(Capacitance<si::capacitance<si::farad>>);
|
||||
static_assert(!Capacitance<si::time<si::second>>);
|
||||
|
||||
static_assert(SurfaceTension<si::surface_tension<si::newton_per_metre>>);
|
||||
static_assert(!SurfaceTension<si::time<si::second>>);
|
||||
|
||||
static_assert(Pressure<si::pressure<si::pascal>>);
|
||||
static_assert(!Pressure<si::time<si::second>>);
|
||||
|
||||
static_assert(MagneticInduction<si::magnetic_induction<si::tesla>>);
|
||||
static_assert(!MagneticInduction<si::time<si::second>>);
|
||||
|
||||
static_assert(MagneticFlux<si::magnetic_flux<si::weber>>);
|
||||
static_assert(!MagneticFlux<si::time<si::second>>);
|
||||
|
||||
static_assert(Inductance<si::inductance<si::henry>>);
|
||||
static_assert(!Inductance<si::time<si::second>>);
|
||||
|
||||
static_assert(Conductance<si::conductance<si::siemens>>);
|
||||
static_assert(!Conductance<si::time<si::second>>);
|
||||
|
||||
// TODO Add when downcasting issue is solved
|
||||
// static_assert(Radioactivity<si::radioactivity<si::becquerel>>);
|
||||
// static_assert(!Radioactivity<si::time<si::second>>);
|
||||
|
||||
static_assert(CatalyticActivity<si::catalytic_activity<si::katal>>);
|
||||
static_assert(!CatalyticActivity<si::time<si::second>>);
|
||||
|
||||
static_assert(AbsorbedDose<si::absorbed_dose<si::gray>>);
|
||||
static_assert(!AbsorbedDose<si::time<si::second>>);
|
||||
|
||||
static_assert(CurrentDensity<si::current_density<si::ampere_per_metre_sq>>);
|
||||
static_assert(!CurrentDensity<si::time<si::second>>);
|
||||
|
||||
static_assert(Concentration<si::concentration<si::mol_per_metre_cub>>);
|
||||
static_assert(!Concentration<si::time<si::second>>);
|
||||
|
||||
static_assert(Luminance<si::luminance<si::candela_per_metre_sq>>);
|
||||
static_assert(!Luminance<si::time<si::second>>);
|
||||
|
||||
static_assert(DynamicViscosity<si::dynamic_viscosity<si::pascal_second>>);
|
||||
static_assert(!DynamicViscosity<si::time<si::second>>);
|
||||
|
||||
static_assert(HeatCapacity<si::heat_capacity<si::joule_per_kelvin>>);
|
||||
static_assert(!HeatCapacity<si::time<si::second>>);
|
||||
|
||||
static_assert(SpecificHeatCapacity<si::specific_heat_capacity<si::joule_per_kilogram_kelvin>>);
|
||||
static_assert(!SpecificHeatCapacity<si::time<si::second>>);
|
||||
|
||||
static_assert(MolarHeatCapacity<si::molar_heat_capacity<si::joule_per_mole_kelvin>>);
|
||||
static_assert(!MolarHeatCapacity<si::time<si::second>>);
|
||||
|
||||
static_assert(ThermalConductivity<si::thermal_conductivity<si::watt_per_metre_kelvin>>);
|
||||
static_assert(!ThermalConductivity<si::time<si::second>>);
|
||||
|
||||
// TODO Add when downcasting issue is solved
|
||||
// static_assert(EnergyDensity<si::energy_density<si::joule_per_metre_cub>>);
|
||||
// static_assert(!EnergyDensity<si::time<si::second>>);
|
||||
|
||||
static_assert(ElectricFieldStrength<si::electric_field_strength<si::volt_per_metre>>);
|
||||
static_assert(!ElectricFieldStrength<si::time<si::second>>);
|
||||
|
||||
static_assert(ChargeDensity<si::charge_density<si::coulomb_per_metre_cub>>);
|
||||
static_assert(!ChargeDensity<si::time<si::second>>);
|
||||
|
||||
static_assert(SurfaceChargeDensity<si::surface_charge_density<si::coulomb_per_metre_sq>>);
|
||||
static_assert(!SurfaceChargeDensity<si::time<si::second>>);
|
||||
|
||||
static_assert(Permittivity<si::permittivity<si::farad_per_metre>>);
|
||||
static_assert(!Permittivity<si::time<si::second>>);
|
||||
|
||||
static_assert(Permeability<si::permeability<si::henry_per_metre>>);
|
||||
static_assert(!Permeability<si::time<si::second>>);
|
||||
|
||||
static_assert(MolarEnergy<si::molar_energy<si::joule_per_mole>>);
|
||||
static_assert(!MolarEnergy<si::time<si::second>>);
|
||||
|
||||
} // namespace
|
@@ -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 <units/bits/basic_concepts.h>
|
||||
#include <units/bits/unit_text.h>
|
||||
#include <units/isq/si/acceleration.h>
|
||||
#include <units/isq/si/fps/fps.h>
|
||||
#include <units/isq/si/time.h>
|
||||
|
||||
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<dim_speed, foot_per_second>() == "ft/s");
|
||||
|
||||
// area
|
||||
static_assert(as_ratio(foot::mag / dimension_unit<dim_length>::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<dim_area, square_foot>() == 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<dim_energy, foot_poundal>() == basic_symbol_text("ft⋅pdl", "ft pdl"));
|
||||
static_assert(detail::unit_text<dim_energy, foot_pound_force>() == 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<dim_power, foot_poundal_per_second>() == basic_symbol_text("ft⋅pdl/s", "ft pdl/s"));
|
||||
static_assert(detail::unit_text<dim_power, foot_pound_force_per_second>() == basic_symbol_text("ft⋅lbf/s", "ft lbf/s"));
|
||||
|
||||
} // namespace
|
@@ -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 <units/isq/si/acceleration.h>
|
||||
#include <units/isq/si/area.h> // IWYU pragma: keep
|
||||
#include <units/isq/si/cgs/cgs.h>
|
||||
#include <units/isq/si/energy.h>
|
||||
#include <units/isq/si/force.h>
|
||||
#include <units/isq/si/length.h> // IWYU pragma: keep
|
||||
#include <units/isq/si/mass.h>
|
||||
#include <units/isq/si/power.h>
|
||||
#include <units/isq/si/pressure.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
#include <units/isq/si/time.h> // IWYU pragma: keep
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units::isq;
|
||||
|
||||
template<units::Quantity Q>
|
||||
inline constexpr units::ratio quantity_ratio = units::as_ratio(units::detail::quantity_magnitude<Q>);
|
||||
|
||||
static_assert(quantity_ratio<si::length<si::metre>> == units::ratio(1));
|
||||
static_assert(quantity_ratio<si::cgs::length<si::cgs::centimetre>> == units::ratio(1, 100));
|
||||
static_assert(quantity_ratio<si::speed<si::metre_per_second>> == units::ratio(1));
|
||||
static_assert(quantity_ratio<si::cgs::speed<si::cgs::centimetre_per_second>> == units::ratio(1, 100));
|
||||
static_assert(quantity_ratio<si::force<si::newton>> ==
|
||||
units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram
|
||||
static_assert(quantity_ratio<si::cgs::force<si::cgs::dyne>> ==
|
||||
units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here
|
||||
|
||||
static_assert(si::cgs::length<si::cgs::centimetre>(100) == si::length<si::metre>(1));
|
||||
static_assert(si::cgs::mass<si::cgs::gram>(1'000) == si::mass<si::kilogram>(1));
|
||||
static_assert(si::cgs::time<si::cgs::second>(1) == si::time<si::second>(1));
|
||||
static_assert(si::cgs::speed<si::cgs::centimetre_per_second>(100) == si::speed<si::metre_per_second>(1));
|
||||
static_assert(si::cgs::area<si::cgs::square_centimetre>(10000) == si::area<si::square_metre>(1));
|
||||
static_assert(si::cgs::acceleration<si::cgs::gal>(100) == si::acceleration<si::metre_per_second_sq>(1));
|
||||
static_assert(si::cgs::force<si::cgs::dyne>(100'000) == si::force<si::newton>(1));
|
||||
static_assert(si::cgs::energy<si::cgs::erg>(10'000'000) == si::energy<si::joule>(1));
|
||||
static_assert(si::cgs::power<si::cgs::erg_per_second>(10'000'000) == si::power<si::watt>(1));
|
||||
static_assert(si::cgs::pressure<si::cgs::barye>(10) == si::pressure<si::pascal>(1));
|
||||
|
||||
namespace si_test {
|
||||
|
||||
using namespace units::isq::si::literals;
|
||||
|
||||
static_assert(si::cgs::length<si::cgs::centimetre>(100) == 1_q_m);
|
||||
static_assert(si::cgs::mass<si::cgs::gram>(1'000) == 1_q_kg);
|
||||
static_assert(si::cgs::time<si::cgs::second>(1) == 1_q_s);
|
||||
static_assert(si::cgs::speed<si::cgs::centimetre_per_second>(100) == 1_q_m_per_s);
|
||||
static_assert(si::cgs::acceleration<si::cgs::gal>(100) == 1_q_m_per_s2);
|
||||
static_assert(si::cgs::force<si::cgs::dyne>(100'000) == 1_q_N);
|
||||
static_assert(si::cgs::energy<si::cgs::erg>(10'000'000) == 1_q_J);
|
||||
static_assert(si::cgs::power<si::cgs::erg_per_second>(10'000'000) == 1_q_W);
|
||||
static_assert(si::cgs::pressure<si::cgs::barye>(10) == 1_q_Pa);
|
||||
|
||||
} // namespace si_test
|
||||
|
||||
namespace cgs_test {
|
||||
|
||||
using namespace units::isq::si::cgs::literals;
|
||||
|
||||
static_assert(100_q_cm == si::length<si::metre>(1));
|
||||
static_assert(1'000_q_g == si::mass<si::kilogram>(1));
|
||||
static_assert(1_q_s == si::time<si::second>(1));
|
||||
static_assert(100_q_cm_per_s == si::speed<si::metre_per_second>(1));
|
||||
static_assert(100_q_Gal == si::acceleration<si::metre_per_second_sq>(1));
|
||||
static_assert(100'000_q_dyn == si::force<si::newton>(1));
|
||||
static_assert(10'000'000_q_erg == si::energy<si::joule>(1));
|
||||
static_assert(10'000'000_q_erg_per_s == si::power<si::watt>(1));
|
||||
static_assert(10_q_Ba == si::pressure<si::pascal>(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<double>(1_q_Pa));
|
||||
|
||||
} // namespace both_test
|
||||
|
||||
namespace cgs_test {
|
||||
|
||||
// addition
|
||||
|
||||
static_assert(100_q_cm + si::length<si::metre>(1) == si::length<si::metre>(2));
|
||||
static_assert(si::length<si::metre>(1) + 100_q_cm == si::length<si::metre>(2));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(100_q_cm) + si::length<si::metre>(1) == si::length<si::metre>(2));
|
||||
static_assert(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(100_q_cm) == si::length<si::metre>(2));
|
||||
static_assert(100_q_cm + quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(1)) == 200_q_cm);
|
||||
static_assert(quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(1)) + 100_q_cm == 200_q_cm);
|
||||
|
||||
// subtraction
|
||||
|
||||
static_assert(500_q_cm - si::length<si::metre>(1) == si::length<si::metre>(4));
|
||||
static_assert(si::length<si::metre>(5) - 100_q_cm == si::length<si::metre>(4));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(500_q_cm) - si::length<si::metre>(1) == si::length<si::metre>(4));
|
||||
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(100_q_cm) == si::length<si::metre>(4));
|
||||
static_assert(500_q_cm - quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(1)) == 400_q_cm);
|
||||
static_assert(quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(5)) - 100_q_cm == 400_q_cm);
|
||||
|
||||
// multiplication
|
||||
|
||||
// TODO Add support for comparing of an unknown_dimension
|
||||
// static_assert(200._q_cm * si::length<si::metre>(2) == si::area<si::square_metre>(4));
|
||||
|
||||
static_assert(quantity_cast<si::dim_length>(200._q_cm) * si::length<si::metre>(2) == si::area<si::square_metre>(4));
|
||||
static_assert(200._q_cm * quantity_cast<si::cgs::dim_length>(si::length<si::metre>(2)) == 40'000_q_cm2);
|
||||
|
||||
// TODO Add support for quantity_cast on an unknown_dimension?
|
||||
// static_assert(quantity_cast<si::area<si::square_metre>>(200_q_cm * si::length<si::metre>(2)) ==
|
||||
// si::area<si::square_metre>(4)); static_assert(quantity_cast<si::dim_area>(200_q_cm * si::length<si::metre>(2)) ==
|
||||
// si::area<si::square_metre>(4)); static_assert(quantity_cast<si::cgs::area<si::cgs::square_centimeters>>(200_q_cm *
|
||||
// si::length<si::metre>(2)) == 40'000_q_cm2); static_assert(quantity_cast<si::cgs::dim_area>(200_q_cm *
|
||||
// si::length<si::metre>(2)) == 40'000_q_cm2);
|
||||
|
||||
// division
|
||||
|
||||
// TODO Add support for comparing of an unknown_dimension
|
||||
// static_assert(si::area<si::square_metre>(4) / 200_q_cm == si::length<si::metre>(2));
|
||||
// static_assert(400._q_cm / si::length<si::metre>(2) == 2);
|
||||
|
||||
static_assert(si::area<si::square_metre>(4) / quantity_cast<si::length<si::metre>>(200_q_cm) ==
|
||||
si::length<si::metre>(2));
|
||||
static_assert(quantity_cast<si::cgs::area<si::cgs::square_centimetre>>(si::area<si::square_metre>(4)) / 200._q_cm ==
|
||||
200_q_cm);
|
||||
|
||||
static_assert(si::cgs::length<si::cgs::centimetre>(50) == si::length<si::centimetre>(50));
|
||||
static_assert(si::cgs::mass<si::cgs::gram>(50) == si::mass<si::gram>(50));
|
||||
|
||||
static_assert(1 / si::cgs::length<si::cgs::centimetre>(50) == 1 / si::length<si::centimetre>(50));
|
||||
static_assert(1 / si::cgs::length<si::metre>(50) == 1 / si::length<si::metre>(50));
|
||||
|
||||
static_assert(1 / si::cgs::mass<si::cgs::gram>(50) == 1 / si::mass<si::gram>(50));
|
||||
static_assert(1 / si::cgs::mass<si::kilogram>(50) == 1 / si::mass<si::kilogram>(50));
|
||||
|
||||
static_assert(si::cgs::length<si::cgs::centimetre>(50) * si::cgs::mass<si::cgs::gram>(50) ==
|
||||
si::length<si::centimetre>(50) * si::mass<si::gram>(50));
|
||||
static_assert(si::cgs::length<si::metre>(50) * si::cgs::mass<si::kilogram>(50) ==
|
||||
si::length<si::metre>(50) * si::mass<si::kilogram>(50));
|
||||
|
||||
static_assert(si::cgs::length<si::cgs::centimetre>(50) / si::cgs::mass<si::cgs::gram>(50) ==
|
||||
si::length<si::centimetre>(50) / si::mass<si::gram>(50));
|
||||
|
||||
} // namespace cgs_test
|
||||
|
||||
} // namespace
|
@@ -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 <units/isq/si/acceleration.h>
|
||||
#include <units/isq/si/area.h>
|
||||
#include <units/isq/si/energy.h>
|
||||
#include <units/isq/si/force.h>
|
||||
#include <units/isq/si/fps/fps.h>
|
||||
#include <units/isq/si/length.h>
|
||||
#include <units/isq/si/mass.h>
|
||||
#include <units/isq/si/power.h>
|
||||
#include <units/isq/si/pressure.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/math.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units::isq;
|
||||
|
||||
static_assert(si::fps::length<si::fps::foot>(1) == si::length<si::metre>(0.3048));
|
||||
static_assert(si::fps::mass<si::fps::pound>(1) == si::mass<si::kilogram>(0.45359237));
|
||||
static_assert(si::fps::time<si::fps::second>(1) == si::time<si::second>(1));
|
||||
static_assert(si::fps::speed<si::fps::foot_per_second>(1) == si::speed<si::metre_per_second>(0.3048));
|
||||
static_assert(si::fps::area<si::fps::square_foot>(1) == si::area<si::square_metre>(0.09290304));
|
||||
static_assert(si::fps::acceleration<si::fps::foot_per_second_sq>(1) ==
|
||||
si::acceleration<si::metre_per_second_sq>(0.3048));
|
||||
static_assert(si::fps::force<si::fps::poundal>(1) > si::force<si::newton>(0.138254) &&
|
||||
si::fps::force<si::fps::poundal>(1) < si::force<si::newton>(0.138256));
|
||||
static_assert(si::fps::energy<si::fps::foot_poundal>(1) > si::energy<si::joule>(0.042140110093804) &&
|
||||
si::fps::energy<si::fps::foot_poundal>(1) < si::energy<si::joule>(0.042140110093806));
|
||||
static_assert(si::fps::power<si::fps::foot_poundal_per_second>(1) > si::power<si::watt>(0.042140110093804) &&
|
||||
si::fps::power<si::fps::foot_poundal_per_second>(1) < si::power<si::watt>(0.042140110093806));
|
||||
static_assert(si::fps::pressure<si::fps::poundal_per_foot_sq>(1) > si::pressure<si::pascal>(1.4881639435) &&
|
||||
si::fps::pressure<si::fps::poundal_per_foot_sq>(1) < si::pressure<si::pascal>(1.4881639437));
|
||||
|
||||
namespace si_literals {
|
||||
|
||||
using namespace units::isq::si::literals;
|
||||
|
||||
static_assert(si::fps::length<si::fps::foot>(1) == 0.3048_q_m);
|
||||
static_assert(si::fps::mass<si::fps::pound>(1) == 0.45359237_q_kg);
|
||||
static_assert(si::fps::time<si::fps::second>(1) == 1_q_s);
|
||||
static_assert(si::fps::speed<si::fps::foot_per_second>(1) == 0.3048_q_m_per_s);
|
||||
static_assert(si::fps::area<si::fps::square_foot>(1) == 0.09290304_q_m2);
|
||||
static_assert(si::fps::acceleration<si::fps::foot_per_second_sq>(1) == 0.3048_q_m_per_s2);
|
||||
static_assert(si::fps::force<si::fps::poundal>(1) > 0.138254_q_N && si::fps::force<si::fps::poundal>(1) < 0.138256_q_N);
|
||||
static_assert(si::fps::energy<si::fps::foot_poundal>(1) > 0.042140110093804_q_J &&
|
||||
si::fps::energy<si::fps::foot_poundal>(1) < 0.042140110093806_q_J);
|
||||
static_assert(si::fps::power<si::fps::foot_poundal_per_second>(1) > 0.042140110093804_q_W &&
|
||||
si::fps::power<si::fps::foot_poundal_per_second>(1) < 0.042140110093806_q_W);
|
||||
static_assert(si::fps::pressure<si::fps::poundal_per_foot_sq>(1) > 1.4881639435_q_Pa &&
|
||||
si::fps::pressure<si::fps::poundal_per_foot_sq>(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<si::metre>(0.3048));
|
||||
static_assert(1_q_lb == si::mass<si::kilogram>(0.45359237));
|
||||
static_assert(1_q_s == si::time<si::second>(1));
|
||||
static_assert(1_q_ft_per_s == si::speed<si::metre_per_second>(0.3048));
|
||||
static_assert(1_q_ft2 == si::area<si::square_metre>(0.09290304));
|
||||
static_assert(1_q_ft_per_s2 == si::acceleration<si::metre_per_second_sq>(0.3048));
|
||||
static_assert(1_q_pdl > si::force<si::newton>(0.138254) && 1_q_pdl < si::force<si::newton>(0.138256));
|
||||
static_assert(1_q_ft_pdl > si::energy<si::joule>(0.042140110093804) &&
|
||||
1_q_ft_pdl < si::energy<si::joule>(0.042140110093806));
|
||||
static_assert(1_q_ft_pdl_per_s > si::power<si::watt>(0.042140110093804) &&
|
||||
1_q_ft_pdl_per_s < si::power<si::watt>(0.042140110093806));
|
||||
static_assert(1_q_pdl_per_ft2 > si::pressure<si::pascal>(1.4881639435) &&
|
||||
1_q_pdl_per_ft2 < si::pressure<si::pascal>(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<si::metre>(1) + 1 * ft == si::length<si::metre>(1.3048));
|
||||
static_assert(1 * ft + si::length<si::metre>(1) == si::length<si::metre>(1.3048));
|
||||
static_assert(is_near(quantity_cast<si::length<si::metre>>(1. * ft / 0.3048) + si::length<si::metre>(1),
|
||||
si::length<si::metre>(2),
|
||||
si::length<si::femtometre>(1))); // 1 m in ft + 1 m
|
||||
static_assert(is_near(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(1. * ft / 0.3048),
|
||||
si::length<si::metre>(2),
|
||||
si::length<si::femtometre>(1))); // 1 m + 1 m in ft
|
||||
static_assert(1 * ft + quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.3048)) ==
|
||||
2 * ft); // 1 ft + 1 ft in m
|
||||
static_assert(quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.3048)) + 1 * ft ==
|
||||
2 * ft); // 1 ft in m + 1 ft
|
||||
|
||||
// substraction
|
||||
|
||||
static_assert(1 * ft - si::length<si::metre>(1) == -si::length<si::metre>(0.6952));
|
||||
static_assert(si::length<si::metre>(1) - 1 * ft == si::length<si::metre>(0.6952));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(6. * ft) - si::length<si::metre>(1) >
|
||||
si::length<si::metre>(0.8287) &&
|
||||
quantity_cast<si::length<si::metre>>(6. * ft) - si::length<si::metre>(1) <
|
||||
si::length<si::metre>(0.8289)); // 6 ft in m - 1 m = ... m
|
||||
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(6 * ft) ==
|
||||
si::length<si::metre>(3.1712)); // 5 m - 6 ft in m = ...
|
||||
static_assert(6. * ft - quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.3048)) ==
|
||||
5. * ft); // 6 ft - 1 ft in m = 5 ft
|
||||
static_assert(quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(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<si::metre>(2) == si::area<si::square_metre>(1.2192));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(2) ==
|
||||
si::area<si::square_metre>(1.2192));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(0.6096) ==
|
||||
si::area<si::square_metre>(0.371612160)); // 2 ft * 2 ft == 4 sq ft
|
||||
static_assert(2. * ft * quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.6096)) == 4._q_ft2);
|
||||
|
||||
// division
|
||||
|
||||
// TODO Add support for comparing of an unknown_dimension
|
||||
// static_assert(si::area<si::square_metre>(4) / 200_q_cm == si::length<si::metre>(2));
|
||||
// static_assert(400._q_cm / si::length<si::metre>(2) == 2);
|
||||
|
||||
static_assert(si::area<si::square_metre>(1.48644864) / quantity_cast<si::length<si::metre>>(4 * ft) ==
|
||||
si::length<si::metre>(1.2192)); // 16 ft2 / 4 ft = 4 ft
|
||||
static_assert(quantity_cast<si::fps::area<si::fps::square_foot>>(si::area<si::square_metre>(1.48644864)) / (4. * ft) ==
|
||||
4. * ft); // 16 ft2 / 4 ft = 4 ft
|
||||
|
||||
} // namespace fps_test
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user