1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Molar flux (base unit mole per square meter second, m⁻² · s⁻¹ · mol).

quantity! {
    /// Molar flux (base unit mole per square meter second, m⁻² · s⁻¹ · mol).
    quantity: MolarFlux; "molar flux";
    /// Dimension of molar flux, L⁻²T⁻¹N (base unit mole per square meter second, m⁻² · s⁻¹ · mol).
    dimension: ISQ<
        N2,     // length
        Z0,     // mass
        N1,     // time
        Z0,     // electric current
        Z0,     // thermodynamic temperature
        P1,     // amount of substance
        Z0>;    // luminous intensity
    units {
        @mole_per_square_meter_second: prefix!(none); "mol/(m² · s)",
            "mole per square meter second", "moles per square meter second";
    }
}

#[cfg(test)]
mod test {
    storage_types! {
        use crate::num::One;
        use crate::si::amount_of_substance as aos;
        use crate::si::molar_flux as mf;
        use crate::si::quantities::*;
        use crate::si::time as t;
        use crate::si::area as area;
        use crate::tests::Test;

        #[test]
        fn check_dimension() {
            let _: MolarFlux<V> = AmountOfSubstance::new::<aos::mole>(V::one())
                / Time::new::<t::second>(V::one())
                / Area::new::<area::square_meter>(V::one());
        }

        #[test]
        fn check_units() {
            test::<aos::mole, t::second, area::square_meter, mf::mole_per_square_meter_second>();

            fn test<N: aos::Conversion<V>, T: t::Conversion<V>, A: area::Conversion<V>, R: mf::Conversion<V>>() {
                Test::assert_approx_eq(&MolarFlux::new::<R>(V::one()),
                    &(AmountOfSubstance::new::<N>(V::one())
                        / Time::new::<T>(V::one())
                        / Area::new::<A>(V::one())));
            }
        }
    }
}