#[cfg(feature="uom")] #[cfg(test)] mod uom_integration { use uom::si; use simple_si_units; #[test] fn spot_check_uom_library(){ // test that the uom lib is working // example from uom docs: { use uom::si::f32::*; use uom::si::length::kilometer; use uom::si::time::second; let length = Length::new::(5.0); let time = Time::new::(15.0); let velocity = length / time; println!("length {:?} / time {:?} = velocity {:?}", length, time, velocity); let x: f32 = velocity.value; println!("{}", x); } // uom unit conversion spot check assert_eq!( si::f64::Length::new::(1000.), si::f64::Length::new::(1.), "uom assert fail: 1000 m per km"); assert_eq!( si::f64::MolarConcentration::new::(1.), si::f64::MolarConcentration::new::(1.), "uom assert fail: 1 mol/m3 = 1 mM"); assert_eq!( si::f64::Velocity::new::(5.) / si::f64::Length::new::(2.), si::f64::Frequency::new::(2.5), "uom assert fail: 5 mps / 2 m = 2.5 Hz"); } #[test] fn uom_equivalence_test() { let x: f64 = 2.5; assert_eq!(simple_si_units::base::Amount{mol: x}.mol, uom::si::f64::AmountOfSubstance::new::(x).value); assert_eq!(simple_si_units::base::Current{A: x}.A, uom::si::f64::ElectricCurrent::new::(x).value); assert_eq!(simple_si_units::base::Distance{m: x}.m, uom::si::f64::Length::new::(x).value); assert_eq!(simple_si_units::base::Luminosity{cd: x}.cd, uom::si::f64::LuminousIntensity::new::(x).value); assert_eq!(simple_si_units::base::Mass{kg: x}.kg, uom::si::f64::Mass::new::(x).value); assert_eq!(simple_si_units::base::Temperature{K: x}.K, uom::si::f64::ThermodynamicTemperature::new::(x).value); assert_eq!(simple_si_units::base::Time{s: x}.s, uom::si::f64::Time::new::(x).value); assert_eq!(simple_si_units::chemical::CatalyticActivity{molps: x}.molps, uom::si::f64::CatalyticActivity::new::(x).value); assert_eq!(simple_si_units::chemical::Concentration{molpm3: x}.molpm3, uom::si::f64::MolarConcentration::new::(x).value); assert_eq!(simple_si_units::chemical::Molality{molpkg: x}.molpkg, uom::si::f64::Molality::new::(x).value); assert_eq!(simple_si_units::chemical::MolarMass{kgpmol: x}.kgpmol, uom::si::f64::MolarMass::new::(x).value); assert_eq!(simple_si_units::chemical::SpecificHeatCapacity{J_per_kgK: x}.J_per_kgK, uom::si::f64::SpecificHeatCapacity::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Conductance{S: x}.S, uom::si::f64::ElectricalConductance::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Capacitance{F: x}.F, uom::si::f64::Capacitance::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Charge{C: x}.C, uom::si::f64::ElectricCharge::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Illuminance{lux: x}.lux, uom::si::f64::Luminance::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Inductance{H: x}.H, uom::si::f64::Inductance::new::(x).value); assert_eq!(simple_si_units::electromagnetic::MagneticFlux{Wb: x}.Wb, uom::si::f64::MagneticFlux::new::(x).value); assert_eq!(simple_si_units::electromagnetic::MagneticFluxDensity{T: x}.T, uom::si::f64::MagneticFluxDensity::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Resistance{Ohm: x}.Ohm, uom::si::f64::ElectricalResistance::new::(x).value); assert_eq!(simple_si_units::electromagnetic::Voltage{V: x}.V, uom::si::f64::ElectricPotential::new::(x).value); assert_eq!(simple_si_units::geometry::Angle{rad: x}.rad, uom::si::f64::Angle::new::(x).value); assert_eq!(simple_si_units::geometry::Area{m2: x}.m2, uom::si::f64::Area::new::(x).value); assert_eq!(simple_si_units::geometry::Volume{m3: x}.m3, uom::si::f64::Volume::new::(x).value); assert_eq!(simple_si_units::mechanical::Acceleration{mps2: x}.mps2, uom::si::f64::Acceleration::new::(x).value); assert_eq!(simple_si_units::mechanical::AngularAcceleration{radps2: x}.radps2, uom::si::f64::AngularAcceleration::new::(x).value); assert_eq!(simple_si_units::mechanical::AngularVelocity{radps: x}.radps, uom::si::f64::AngularVelocity::new::(x).value); assert_eq!(simple_si_units::mechanical::AreaDensity{kgpm2: x}.kgpm2, uom::si::f64::ArealMassDensity::new::(x).value); assert_eq!(simple_si_units::mechanical::Density{kgpm3: x}.kgpm3, uom::si::f64::MassDensity::new::(x).value); assert_eq!(simple_si_units::mechanical::Energy{J: x}.J, uom::si::f64::Energy::new::(x).value); assert_eq!(simple_si_units::mechanical::Force{N: x}.N, uom::si::f64::Force::new::(x).value); assert_eq!(simple_si_units::mechanical::Frequency{Hz: x}.Hz, uom::si::f64::Frequency::new::(x).value); assert_eq!(simple_si_units::mechanical::MomentOfInertia{kgm2: x}.kgm2, uom::si::f64::MomentOfInertia::new::(x).value); assert_eq!(simple_si_units::mechanical::Momentum{kgmps: x}.kgmps, uom::si::f64::Momentum::new::(x).value); assert_eq!(simple_si_units::mechanical::Power{W: x}.W, uom::si::f64::Power::new::(x).value); assert_eq!(simple_si_units::mechanical::Pressure{Pa: x}.Pa, uom::si::f64::Pressure::new::(x).value); assert_eq!(simple_si_units::mechanical::Torque{Nm: x}.Nm, uom::si::f64::Torque::new::(x).value); assert_eq!(simple_si_units::mechanical::Velocity{mps: x}.mps, uom::si::f64::Velocity::new::(x).value); assert_eq!(simple_si_units::nuclear::Radioactivity{Bq: x}.Bq, uom::si::f64::Radioactivity::new::(x).value); assert_eq!(simple_si_units::base::InverseDistance{per_m: x}.per_m, uom::si::f64::LinearNumberDensity::new::(x).value); assert_eq!(simple_si_units::base::InverseTemperature{per_K: x}.per_K, uom::si::f64::TemperatureCoefficient::new::(x).value); assert_eq!(simple_si_units::chemical::MolarVolume{m3_per_mol: x}.m3_per_mol, uom::si::f64::MolarVolume::new::(x).value); assert_eq!(simple_si_units::geometry::InverseArea{per_m2: x}.per_m2, uom::si::f64::ArealNumberDensity::new::(x).value); assert_eq!(simple_si_units::geometry::InverseVolume{per_m3: x}.per_m3, uom::si::f64::VolumetricNumberDensity::new::(x).value); assert_eq!(simple_si_units::geometry::SolidAngle{sr: x}.sr, uom::si::f64::SolidAngle::new::(x).value); assert_eq!(simple_si_units::mechanical::AreaPerMass{m2_per_kg: x}.m2_per_kg, uom::si::f64::SpecificArea::new::(x).value); assert_eq!(simple_si_units::mechanical::VolumePerMass{m3_per_kg: x}.m3_per_kg, uom::si::f64::SpecificVolume::new::(x).value); } #[test] fn into_uom_test_f64(){ let x: f64 = 2.5; assert!(uom::si::f64::AmountOfSubstance::new::(x) == simple_si_units::base::Amount{mol: x}.into()); assert!(uom::si::f64::ElectricCurrent::new::(x) == simple_si_units::base::Current{A: x}.into()); assert!(uom::si::f64::Length::new::(x) == simple_si_units::base::Distance{m: x}.into()); assert!(uom::si::f64::LuminousIntensity::new::(x) == simple_si_units::base::Luminosity{cd: x}.into()); assert!(uom::si::f64::Mass::new::(x) == simple_si_units::base::Mass{kg: x}.into()); assert!(uom::si::f64::ThermodynamicTemperature::new::(x) == simple_si_units::base::Temperature{K: x}.into()); assert!(uom::si::f64::Time::new::(x) == simple_si_units::base::Time{s: x}.into()); assert!(uom::si::f64::CatalyticActivity::new::(x) == simple_si_units::chemical::CatalyticActivity{molps: x}.into()); assert!(uom::si::f64::MolarConcentration::new::(x) == simple_si_units::chemical::Concentration{molpm3: x}.into()); assert!(uom::si::f64::Molality::new::(x) == simple_si_units::chemical::Molality{molpkg: x}.into()); assert!(uom::si::f64::MolarMass::new::(x) == simple_si_units::chemical::MolarMass{kgpmol: x}.into()); assert!(uom::si::f64::SpecificHeatCapacity::new::(x) == simple_si_units::chemical::SpecificHeatCapacity{J_per_kgK: x}.into()); assert!(uom::si::f64::Capacitance::new::(x) == simple_si_units::electromagnetic::Capacitance{F: x}.into()); assert!(uom::si::f64::ElectricCharge::new::(x) == simple_si_units::electromagnetic::Charge{C: x}.into()); assert!(uom::si::f64::ElectricalConductance::new::(x) == simple_si_units::electromagnetic::Conductance{S: x}.into()); assert!(uom::si::f64::Luminance::new::(x) == simple_si_units::electromagnetic::Illuminance{lux: x}.into()); assert!(uom::si::f64::Inductance::new::(x) == simple_si_units::electromagnetic::Inductance{H: x}.into()); assert!(uom::si::f64::MagneticFlux::new::(x) == simple_si_units::electromagnetic::MagneticFlux{Wb: x}.into()); assert!(uom::si::f64::MagneticFluxDensity::new::(x) == simple_si_units::electromagnetic::MagneticFluxDensity{T: x}.into()); assert!(uom::si::f64::ElectricalResistance::new::(x) == simple_si_units::electromagnetic::Resistance{Ohm: x}.into()); assert!(uom::si::f64::ElectricPotential::new::(x) == simple_si_units::electromagnetic::Voltage{V: x}.into()); assert!(uom::si::f64::Angle::new::(x) == simple_si_units::geometry::Angle{rad: x}.into()); assert!(uom::si::f64::Area::new::(x) == simple_si_units::geometry::Area{m2: x}.into()); assert!(uom::si::f64::Volume::new::(x) == simple_si_units::geometry::Volume{m3: x}.into()); assert!(uom::si::f64::Acceleration::new::(x) == simple_si_units::mechanical::Acceleration{mps2: x}.into()); assert!(uom::si::f64::AngularAcceleration::new::(x) == simple_si_units::mechanical::AngularAcceleration{radps2: x}.into()); assert!(uom::si::f64::AngularVelocity::new::(x) == simple_si_units::mechanical::AngularVelocity{radps: x}.into()); assert!(uom::si::f64::ArealMassDensity::new::(x) == simple_si_units::mechanical::AreaDensity{kgpm2: x}.into()); assert!(uom::si::f64::MassDensity::new::(x) == simple_si_units::mechanical::Density{kgpm3: x}.into()); assert!(uom::si::f64::Energy::new::(x) == simple_si_units::mechanical::Energy{J: x}.into()); assert!(uom::si::f64::Force::new::(x) == simple_si_units::mechanical::Force{N: x}.into()); assert!(uom::si::f64::Frequency::new::(x) == simple_si_units::mechanical::Frequency{Hz: x}.into()); assert!(uom::si::f64::MomentOfInertia::new::(x) == simple_si_units::mechanical::MomentOfInertia{kgm2: x}.into()); assert!(uom::si::f64::Momentum::new::(x) == simple_si_units::mechanical::Momentum{kgmps: x}.into()); assert!(uom::si::f64::Power::new::(x) == simple_si_units::mechanical::Power{W: x}.into()); assert!(uom::si::f64::Pressure::new::(x) == simple_si_units::mechanical::Pressure{Pa: x}.into()); assert!(uom::si::f64::Torque::new::(x) == simple_si_units::mechanical::Torque{Nm: x}.into()); assert!(uom::si::f64::Velocity::new::(x) == simple_si_units::mechanical::Velocity{mps: x}.into()); assert!(uom::si::f64::Radioactivity::new::(x) == simple_si_units::nuclear::Radioactivity{Bq: x}.into()); assert!(uom::si::f64::LinearNumberDensity::new::(x) == simple_si_units::base::InverseDistance{per_m: x}.into()); assert!(uom::si::f64::TemperatureCoefficient::new::(x) == simple_si_units::base::InverseTemperature{per_K: x}.into()); assert!(uom::si::f64::MolarVolume::new::(x) == simple_si_units::chemical::MolarVolume{m3_per_mol: x}.into()); assert!(uom::si::f64::ArealNumberDensity::new::(x) == simple_si_units::geometry::InverseArea{per_m2: x}.into()); assert!(uom::si::f64::VolumetricNumberDensity::new::(x) == simple_si_units::geometry::InverseVolume{per_m3: x}.into()); assert!(uom::si::f64::SolidAngle::new::(x) == simple_si_units::geometry::SolidAngle{sr: x}.into()); assert!(uom::si::f64::SpecificArea::new::(x) == simple_si_units::mechanical::AreaPerMass{m2_per_kg: x}.into()); assert!(uom::si::f64::SpecificVolume::new::(x) == simple_si_units::mechanical::VolumePerMass{m3_per_kg: x}.into()); } #[test] fn into_uom_test_f32(){ let x: f32 = 2.5; assert!(uom::si::f32::AmountOfSubstance::new::(x) == simple_si_units::base::Amount{mol: x}.into()); assert!(uom::si::f32::ElectricCurrent::new::(x) == simple_si_units::base::Current{A: x}.into()); assert!(uom::si::f32::Length::new::(x) == simple_si_units::base::Distance{m: x}.into()); assert!(uom::si::f32::LuminousIntensity::new::(x) == simple_si_units::base::Luminosity{cd: x}.into()); assert!(uom::si::f32::Mass::new::(x) == simple_si_units::base::Mass{kg: x}.into()); assert!(uom::si::f32::ThermodynamicTemperature::new::(x) == simple_si_units::base::Temperature{K: x}.into()); assert!(uom::si::f32::Time::new::(x) == simple_si_units::base::Time{s: x}.into()); assert!(uom::si::f32::CatalyticActivity::new::(x) == simple_si_units::chemical::CatalyticActivity{molps: x}.into()); assert!(uom::si::f32::MolarConcentration::new::(x) == simple_si_units::chemical::Concentration{molpm3: x}.into()); assert!(uom::si::f32::Molality::new::(x) == simple_si_units::chemical::Molality{molpkg: x}.into()); assert!(uom::si::f32::MolarMass::new::(x) == simple_si_units::chemical::MolarMass{kgpmol: x}.into()); assert!(uom::si::f32::SpecificHeatCapacity::new::(x) == simple_si_units::chemical::SpecificHeatCapacity{J_per_kgK: x}.into()); assert!(uom::si::f32::Capacitance::new::(x) == simple_si_units::electromagnetic::Capacitance{F: x}.into()); assert!(uom::si::f32::ElectricCharge::new::(x) == simple_si_units::electromagnetic::Charge{C: x}.into()); assert!(uom::si::f32::ElectricalConductance::new::(x) == simple_si_units::electromagnetic::Conductance{S: x}.into()); assert!(uom::si::f32::Luminance::new::(x) == simple_si_units::electromagnetic::Illuminance{lux: x}.into()); assert!(uom::si::f32::Inductance::new::(x) == simple_si_units::electromagnetic::Inductance{H: x}.into()); assert!(uom::si::f32::MagneticFlux::new::(x) == simple_si_units::electromagnetic::MagneticFlux{Wb: x}.into()); assert!(uom::si::f32::MagneticFluxDensity::new::(x) == simple_si_units::electromagnetic::MagneticFluxDensity{T: x}.into()); assert!(uom::si::f32::ElectricalResistance::new::(x) == simple_si_units::electromagnetic::Resistance{Ohm: x}.into()); assert!(uom::si::f32::ElectricPotential::new::(x) == simple_si_units::electromagnetic::Voltage{V: x}.into()); assert!(uom::si::f32::Angle::new::(x) == simple_si_units::geometry::Angle{rad: x}.into()); assert!(uom::si::f32::Area::new::(x) == simple_si_units::geometry::Area{m2: x}.into()); assert!(uom::si::f32::Volume::new::(x) == simple_si_units::geometry::Volume{m3: x}.into()); assert!(uom::si::f32::Acceleration::new::(x) == simple_si_units::mechanical::Acceleration{mps2: x}.into()); assert!(uom::si::f32::AngularAcceleration::new::(x) == simple_si_units::mechanical::AngularAcceleration{radps2: x}.into()); assert!(uom::si::f32::AngularVelocity::new::(x) == simple_si_units::mechanical::AngularVelocity{radps: x}.into()); assert!(uom::si::f32::ArealMassDensity::new::(x) == simple_si_units::mechanical::AreaDensity{kgpm2: x}.into()); assert!(uom::si::f32::MassDensity::new::(x) == simple_si_units::mechanical::Density{kgpm3: x}.into()); assert!(uom::si::f32::Energy::new::(x) == simple_si_units::mechanical::Energy{J: x}.into()); assert!(uom::si::f32::Force::new::(x) == simple_si_units::mechanical::Force{N: x}.into()); assert!(uom::si::f32::Frequency::new::(x) == simple_si_units::mechanical::Frequency{Hz: x}.into()); assert!(uom::si::f32::MomentOfInertia::new::(x) == simple_si_units::mechanical::MomentOfInertia{kgm2: x}.into()); assert!(uom::si::f32::Momentum::new::(x) == simple_si_units::mechanical::Momentum{kgmps: x}.into()); assert!(uom::si::f32::Power::new::(x) == simple_si_units::mechanical::Power{W: x}.into()); assert!(uom::si::f32::Pressure::new::(x) == simple_si_units::mechanical::Pressure{Pa: x}.into()); assert!(uom::si::f32::Torque::new::(x) == simple_si_units::mechanical::Torque{Nm: x}.into()); assert!(uom::si::f32::Velocity::new::(x) == simple_si_units::mechanical::Velocity{mps: x}.into()); assert!(uom::si::f32::Radioactivity::new::(x) == simple_si_units::nuclear::Radioactivity{Bq: x}.into()); assert!(uom::si::f32::LinearNumberDensity::new::(x) == simple_si_units::base::InverseDistance{per_m: x}.into()); assert!(uom::si::f32::TemperatureCoefficient::new::(x) == simple_si_units::base::InverseTemperature{per_K: x}.into()); assert!(uom::si::f32::MolarVolume::new::(x) == simple_si_units::chemical::MolarVolume{m3_per_mol: x}.into()); assert!(uom::si::f32::ArealNumberDensity::new::(x) == simple_si_units::geometry::InverseArea{per_m2: x}.into()); assert!(uom::si::f32::VolumetricNumberDensity::new::(x) == simple_si_units::geometry::InverseVolume{per_m3: x}.into()); assert!(uom::si::f32::SolidAngle::new::(x) == simple_si_units::geometry::SolidAngle{sr: x}.into()); assert!(uom::si::f32::SpecificArea::new::(x) == simple_si_units::mechanical::AreaPerMass{m2_per_kg: x}.into()); assert!(uom::si::f32::SpecificVolume::new::(x) == simple_si_units::mechanical::VolumePerMass{m3_per_kg: x}.into()); } #[test] fn from_uom_test_f64(){ let x: f64 = 2.5; assert!(simple_si_units::base::Amount::from( uom::si::f64::AmountOfSubstance::new::(x) ) == simple_si_units::base::Amount{mol: x}); assert!(simple_si_units::base::Current::from( uom::si::f64::ElectricCurrent::new::(x) ) == simple_si_units::base::Current{A: x}); assert!(simple_si_units::base::Distance::from( uom::si::f64::Length::new::(x) ) == simple_si_units::base::Distance{m: x}); assert!(simple_si_units::base::Luminosity::from( uom::si::f64::LuminousIntensity::new::(x) ) == simple_si_units::base::Luminosity{cd: x}); assert!(simple_si_units::base::Mass::from( uom::si::f64::Mass::new::(x) ) == simple_si_units::base::Mass{kg: x}); assert!(simple_si_units::base::Temperature::from( uom::si::f64::ThermodynamicTemperature::new::(x) ) == simple_si_units::base::Temperature{K: x}); assert!(simple_si_units::base::Time::from( uom::si::f64::Time::new::(x) ) == simple_si_units::base::Time{s: x}); assert!(simple_si_units::chemical::CatalyticActivity::from( uom::si::f64::CatalyticActivity::new::(x) ) == simple_si_units::chemical::CatalyticActivity{molps: x}); assert!(simple_si_units::chemical::Concentration::from( uom::si::f64::MolarConcentration::new::(x) ) == simple_si_units::chemical::Concentration{molpm3: x}); assert!(simple_si_units::chemical::Molality::from( uom::si::f64::Molality::new::(x) ) == simple_si_units::chemical::Molality{molpkg: x}); assert!(simple_si_units::chemical::MolarMass::from( uom::si::f64::MolarMass::new::(x) ) == simple_si_units::chemical::MolarMass{kgpmol: x}); assert!(simple_si_units::chemical::SpecificHeatCapacity::from( uom::si::f64::SpecificHeatCapacity::new::(x) ) == simple_si_units::chemical::SpecificHeatCapacity{J_per_kgK: x}); assert!(simple_si_units::electromagnetic::Capacitance::from( uom::si::f64::Capacitance::new::(x) ) == simple_si_units::electromagnetic::Capacitance{F: x}); assert!(simple_si_units::electromagnetic::Charge::from( uom::si::f64::ElectricCharge::new::(x) ) == simple_si_units::electromagnetic::Charge{C: x}); assert!(simple_si_units::electromagnetic::Conductance::from( uom::si::f64::ElectricalConductance::new::(x) ) == simple_si_units::electromagnetic::Conductance{S: x}); assert!(simple_si_units::electromagnetic::Illuminance::from( uom::si::f64::Luminance::new::(x) ) == simple_si_units::electromagnetic::Illuminance{lux: x}); assert!(simple_si_units::electromagnetic::Inductance::from( uom::si::f64::Inductance::new::(x) ) == simple_si_units::electromagnetic::Inductance{H: x}); assert!(simple_si_units::electromagnetic::MagneticFlux::from( uom::si::f64::MagneticFlux::new::(x) ) == simple_si_units::electromagnetic::MagneticFlux{Wb: x}); assert!(simple_si_units::electromagnetic::MagneticFluxDensity::from( uom::si::f64::MagneticFluxDensity::new::(x) ) == simple_si_units::electromagnetic::MagneticFluxDensity{T: x}); assert!(simple_si_units::electromagnetic::Resistance::from( uom::si::f64::ElectricalResistance::new::(x) ) == simple_si_units::electromagnetic::Resistance{Ohm: x}); assert!(simple_si_units::electromagnetic::Voltage::from( uom::si::f64::ElectricPotential::new::(x) ) == simple_si_units::electromagnetic::Voltage{V: x}); assert!(simple_si_units::geometry::Angle::from( uom::si::f64::Angle::new::(x) ) == simple_si_units::geometry::Angle{rad: x}); assert!(simple_si_units::geometry::Area::from( uom::si::f64::Area::new::(x) ) == simple_si_units::geometry::Area{m2: x}); assert!(simple_si_units::geometry::Volume::from( uom::si::f64::Volume::new::(x) ) == simple_si_units::geometry::Volume{m3: x}); assert!(simple_si_units::mechanical::Acceleration::from( uom::si::f64::Acceleration::new::(x) ) == simple_si_units::mechanical::Acceleration{mps2: x}); assert!(simple_si_units::mechanical::AngularAcceleration::from( uom::si::f64::AngularAcceleration::new::(x) ) == simple_si_units::mechanical::AngularAcceleration{radps2: x}); assert!(simple_si_units::mechanical::AngularVelocity::from( uom::si::f64::AngularVelocity::new::(x) ) == simple_si_units::mechanical::AngularVelocity{radps: x}); assert!(simple_si_units::mechanical::AreaDensity::from( uom::si::f64::ArealMassDensity::new::(x) ) == simple_si_units::mechanical::AreaDensity{kgpm2: x}); assert!(simple_si_units::mechanical::Density::from( uom::si::f64::MassDensity::new::(x) ) == simple_si_units::mechanical::Density{kgpm3: x}); assert!(simple_si_units::mechanical::Energy::from( uom::si::f64::Energy::new::(x) ) == simple_si_units::mechanical::Energy{J: x}); assert!(simple_si_units::mechanical::Force::from( uom::si::f64::Force::new::(x) ) == simple_si_units::mechanical::Force{N: x}); assert!(simple_si_units::mechanical::Frequency::from( uom::si::f64::Frequency::new::(x) ) == simple_si_units::mechanical::Frequency{Hz: x}); assert!(simple_si_units::mechanical::MomentOfInertia::from( uom::si::f64::MomentOfInertia::new::(x) ) == simple_si_units::mechanical::MomentOfInertia{kgm2: x}); assert!(simple_si_units::mechanical::Momentum::from( uom::si::f64::Momentum::new::(x) ) == simple_si_units::mechanical::Momentum{kgmps: x}); assert!(simple_si_units::mechanical::Power::from( uom::si::f64::Power::new::(x) ) == simple_si_units::mechanical::Power{W: x}); assert!(simple_si_units::mechanical::Pressure::from( uom::si::f64::Pressure::new::(x) ) == simple_si_units::mechanical::Pressure{Pa: x}); assert!(simple_si_units::mechanical::Torque::from( uom::si::f64::Torque::new::(x) ) == simple_si_units::mechanical::Torque{Nm: x}); assert!(simple_si_units::mechanical::Velocity::from( uom::si::f64::Velocity::new::(x) ) == simple_si_units::mechanical::Velocity{mps: x}); assert!(simple_si_units::nuclear::Radioactivity::from( uom::si::f64::Radioactivity::new::(x) ) == simple_si_units::nuclear::Radioactivity{Bq: x}); assert!(simple_si_units::base::InverseDistance::from( uom::si::f64::LinearNumberDensity::new::(x) ) == simple_si_units::base::InverseDistance{per_m: x}); assert!(simple_si_units::base::InverseTemperature::from( uom::si::f64::TemperatureCoefficient::new::(x) ) == simple_si_units::base::InverseTemperature{per_K: x}); assert!(simple_si_units::chemical::MolarVolume::from( uom::si::f64::MolarVolume::new::(x) ) == simple_si_units::chemical::MolarVolume{m3_per_mol: x}); assert!(simple_si_units::geometry::InverseArea::from( uom::si::f64::ArealNumberDensity::new::(x) ) == simple_si_units::geometry::InverseArea{per_m2: x}); assert!(simple_si_units::geometry::InverseVolume::from( uom::si::f64::VolumetricNumberDensity::new::(x) ) == simple_si_units::geometry::InverseVolume{per_m3: x}); assert!(simple_si_units::geometry::SolidAngle::from( uom::si::f64::SolidAngle::new::(x) ) == simple_si_units::geometry::SolidAngle{sr: x}); assert!(simple_si_units::mechanical::AreaPerMass::from( uom::si::f64::SpecificArea::new::(x) ) == simple_si_units::mechanical::AreaPerMass{m2_per_kg: x}); assert!(simple_si_units::mechanical::VolumePerMass::from( uom::si::f64::SpecificVolume::new::(x) ) == simple_si_units::mechanical::VolumePerMass{m3_per_kg: x}); } #[test] fn from_uom_test_f32(){ let x: f32 = 2.5; assert!(simple_si_units::base::Amount::from( uom::si::f32::AmountOfSubstance::new::(x) ) == simple_si_units::base::Amount{mol: x}); assert!(simple_si_units::base::Current::from( uom::si::f32::ElectricCurrent::new::(x) ) == simple_si_units::base::Current{A: x}); assert!(simple_si_units::base::Distance::from( uom::si::f32::Length::new::(x) ) == simple_si_units::base::Distance{m: x}); assert!(simple_si_units::base::Luminosity::from( uom::si::f32::LuminousIntensity::new::(x) ) == simple_si_units::base::Luminosity{cd: x}); assert!(simple_si_units::base::Mass::from( uom::si::f32::Mass::new::(x) ) == simple_si_units::base::Mass{kg: x}); assert!(simple_si_units::base::Temperature::from( uom::si::f32::ThermodynamicTemperature::new::(x) ) == simple_si_units::base::Temperature{K: x}); assert!(simple_si_units::base::Time::from( uom::si::f32::Time::new::(x) ) == simple_si_units::base::Time{s: x}); assert!(simple_si_units::chemical::CatalyticActivity::from( uom::si::f32::CatalyticActivity::new::(x) ) == simple_si_units::chemical::CatalyticActivity{molps: x}); assert!(simple_si_units::chemical::Molality::from( uom::si::f32::Molality::new::(x) ) == simple_si_units::chemical::Molality{molpkg: x}); assert!(simple_si_units::chemical::MolarMass::from( uom::si::f32::MolarMass::new::(x) ) == simple_si_units::chemical::MolarMass{kgpmol: x}); assert!(simple_si_units::chemical::SpecificHeatCapacity::from( uom::si::f32::SpecificHeatCapacity::new::(x) ) == simple_si_units::chemical::SpecificHeatCapacity{J_per_kgK: x}); assert!(simple_si_units::chemical::Concentration::from( uom::si::f32::MolarConcentration::new::(x) ) == simple_si_units::chemical::Concentration{molpm3: x}); assert!(simple_si_units::electromagnetic::Capacitance::from( uom::si::f32::Capacitance::new::(x) ) == simple_si_units::electromagnetic::Capacitance{F: x}); assert!(simple_si_units::electromagnetic::Charge::from( uom::si::f32::ElectricCharge::new::(x) ) == simple_si_units::electromagnetic::Charge{C: x}); assert!(simple_si_units::electromagnetic::Conductance::from( uom::si::f32::ElectricalConductance::new::(x) ) == simple_si_units::electromagnetic::Conductance{S: x}); assert!(simple_si_units::electromagnetic::Illuminance::from( uom::si::f32::Luminance::new::(x) ) == simple_si_units::electromagnetic::Illuminance{lux: x}); assert!(simple_si_units::electromagnetic::Inductance::from( uom::si::f32::Inductance::new::(x) ) == simple_si_units::electromagnetic::Inductance{H: x}); assert!(simple_si_units::electromagnetic::MagneticFlux::from( uom::si::f32::MagneticFlux::new::(x) ) == simple_si_units::electromagnetic::MagneticFlux{Wb: x}); assert!(simple_si_units::electromagnetic::MagneticFluxDensity::from( uom::si::f32::MagneticFluxDensity::new::(x) ) == simple_si_units::electromagnetic::MagneticFluxDensity{T: x}); assert!(simple_si_units::electromagnetic::Resistance::from( uom::si::f32::ElectricalResistance::new::(x) ) == simple_si_units::electromagnetic::Resistance{Ohm: x}); assert!(simple_si_units::electromagnetic::Voltage::from( uom::si::f32::ElectricPotential::new::(x) ) == simple_si_units::electromagnetic::Voltage{V: x}); assert!(simple_si_units::geometry::Angle::from( uom::si::f32::Angle::new::(x) ) == simple_si_units::geometry::Angle{rad: x}); assert!(simple_si_units::geometry::Area::from( uom::si::f32::Area::new::(x) ) == simple_si_units::geometry::Area{m2: x}); assert!(simple_si_units::geometry::Volume::from( uom::si::f32::Volume::new::(x) ) == simple_si_units::geometry::Volume{m3: x}); assert!(simple_si_units::mechanical::Acceleration::from( uom::si::f32::Acceleration::new::(x) ) == simple_si_units::mechanical::Acceleration{mps2: x}); assert!(simple_si_units::mechanical::AngularAcceleration::from( uom::si::f32::AngularAcceleration::new::(x) ) == simple_si_units::mechanical::AngularAcceleration{radps2: x}); assert!(simple_si_units::mechanical::AngularVelocity::from( uom::si::f32::AngularVelocity::new::(x) ) == simple_si_units::mechanical::AngularVelocity{radps: x}); assert!(simple_si_units::mechanical::AreaDensity::from( uom::si::f32::ArealMassDensity::new::(x) ) == simple_si_units::mechanical::AreaDensity{kgpm2: x}); assert!(simple_si_units::mechanical::Density::from( uom::si::f32::MassDensity::new::(x) ) == simple_si_units::mechanical::Density{kgpm3: x}); assert!(simple_si_units::mechanical::Energy::from( uom::si::f32::Energy::new::(x) ) == simple_si_units::mechanical::Energy{J: x}); assert!(simple_si_units::mechanical::Force::from( uom::si::f32::Force::new::(x) ) == simple_si_units::mechanical::Force{N: x}); assert!(simple_si_units::mechanical::Frequency::from( uom::si::f32::Frequency::new::(x) ) == simple_si_units::mechanical::Frequency{Hz: x}); assert!(simple_si_units::mechanical::MomentOfInertia::from( uom::si::f32::MomentOfInertia::new::(x) ) == simple_si_units::mechanical::MomentOfInertia{kgm2: x}); assert!(simple_si_units::mechanical::Momentum::from( uom::si::f32::Momentum::new::(x) ) == simple_si_units::mechanical::Momentum{kgmps: x}); assert!(simple_si_units::mechanical::Power::from( uom::si::f32::Power::new::(x) ) == simple_si_units::mechanical::Power{W: x}); assert!(simple_si_units::mechanical::Pressure::from( uom::si::f32::Pressure::new::(x) ) == simple_si_units::mechanical::Pressure{Pa: x}); assert!(simple_si_units::mechanical::Torque::from( uom::si::f32::Torque::new::(x) ) == simple_si_units::mechanical::Torque{Nm: x}); assert!(simple_si_units::mechanical::Velocity::from( uom::si::f32::Velocity::new::(x) ) == simple_si_units::mechanical::Velocity{mps: x}); assert!(simple_si_units::nuclear::Radioactivity::from( uom::si::f32::Radioactivity::new::(x) ) == simple_si_units::nuclear::Radioactivity{Bq: x}); assert!(simple_si_units::base::InverseDistance::from( uom::si::f32::LinearNumberDensity::new::(x) ) == simple_si_units::base::InverseDistance{per_m: x}); assert!(simple_si_units::base::InverseTemperature::from( uom::si::f32::TemperatureCoefficient::new::(x) ) == simple_si_units::base::InverseTemperature{per_K: x}); assert!(simple_si_units::chemical::MolarVolume::from( uom::si::f32::MolarVolume::new::(x) ) == simple_si_units::chemical::MolarVolume{m3_per_mol: x}); assert!(simple_si_units::geometry::InverseArea::from( uom::si::f32::ArealNumberDensity::new::(x) ) == simple_si_units::geometry::InverseArea{per_m2: x}); assert!(simple_si_units::geometry::InverseVolume::from( uom::si::f32::VolumetricNumberDensity::new::(x) ) == simple_si_units::geometry::InverseVolume{per_m3: x}); assert!(simple_si_units::geometry::SolidAngle::from( uom::si::f32::SolidAngle::new::(x) ) == simple_si_units::geometry::SolidAngle{sr: x}); assert!(simple_si_units::mechanical::AreaPerMass::from( uom::si::f32::SpecificArea::new::(x) ) == simple_si_units::mechanical::AreaPerMass{m2_per_kg: x}); assert!(simple_si_units::mechanical::VolumePerMass::from( uom::si::f32::SpecificVolume::new::(x) ) == simple_si_units::mechanical::VolumePerMass{m3_per_kg: x}); } }