|
| 1 | +//! Molality (base unit mole per kilogram, kg⁻¹ · mol). |
| 2 | +
|
| 3 | +quantity! { |
| 4 | + /// Molality (base unit mole per kilogram, kg⁻¹ · mol). |
| 5 | + quantity: Molality; "molality"; |
| 6 | + /// Dimension of molality, M⁻¹N (base unit mole per kilogram, kg⁻¹ · mol). |
| 7 | + dimension: ISQ< |
| 8 | + Z0, // length |
| 9 | + N1, // mass |
| 10 | + Z0, // time |
| 11 | + Z0, // electric current |
| 12 | + Z0, // thermodynamic temperature |
| 13 | + P1, // amount of substance |
| 14 | + Z0>; // luminous intensity |
| 15 | + kind: dyn (crate::si::marker::ConstituentConcentrationKind); |
| 16 | + |
| 17 | + units { |
| 18 | + @mole_per_kilogram: prefix!(none); |
| 19 | + "mol/kg", "mole per kilogram", "moles per kilogram"; |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +#[cfg(test)] |
| 24 | +mod tests { |
| 25 | + storage_types! { |
| 26 | + use crate::num::One; |
| 27 | + use crate::si::amount_of_substance as aos; |
| 28 | + use crate::si::mass as m; |
| 29 | + use crate::si::molality as mol; |
| 30 | + use crate::si::quantities::*; |
| 31 | + use crate::tests::Test; |
| 32 | + |
| 33 | + #[test] |
| 34 | + fn check_dimension() { |
| 35 | + let _: Molality<V> = (AmountOfSubstance::new::<aos::mole>(V::one()) |
| 36 | + / Mass::new::<m::kilogram>(V::one())).into(); |
| 37 | + } |
| 38 | + |
| 39 | + #[test] |
| 40 | + fn check_units() { |
| 41 | + |
| 42 | + test::<aos::mole, m::kilogram, mol::mole_per_kilogram>(); |
| 43 | + |
| 44 | + fn test<AOS: aos::Conversion<V>, M: m::Conversion<V>, MOL: mol::Conversion<V>>() { |
| 45 | + Test::assert_approx_eq(&Molality::new::<MOL>(V::one()), |
| 46 | + &(AmountOfSubstance::new::<AOS>(V::one()) / |
| 47 | + Mass::new::<M>(V::one())).into()); |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments