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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Electrical resistance (base unit ohm, m² · kg · s⁻³ · A⁻²).

quantity! {
    /// Electrical resistance (base unit ohm, m² · kg · s⁻³ · A⁻²).
    quantity: ElectricalResistance; "electrical resistance";
    /// Dimension of electrical resistance, L²MT⁻³I⁻² (base unit ohm, m² · kg · s⁻³ · A⁻²).
    dimension: ISQ<
        P2,     // length
        P1,     // mass
        N3,     // time
        N2,     // electric current
        Z0,     // thermodynamic temperature
        Z0,     // amount of substance
        Z0>;    // luminous intensity
    units {
        @yottaohm: prefix!(yotta); "YΩ", "yottaohm", "yottaohms";
        @zettaohm: prefix!(zetta); "ZΩ", "zettaohm", "zettaohms";
        @exaohm: prefix!(exa); "EΩ", "exaohm", "exaohms";
        @petaohm: prefix!(peta); "PΩ", "petaohm", "petaohms";
        @teraohm: prefix!(tera); "TΩ", "teraohm", "teraohms";
        @gigaohm: prefix!(giga); "GΩ", "gigaohm", "gigaohms";
        @megaohm: prefix!(mega); "MΩ", "megaohm", "megaohms";
        @kiloohm: prefix!(kilo); "kΩ", "kiloohm", "kiloohms";
        @hectoohm: prefix!(hecto); "hΩ", "hectoohm", "hectoohms";
        @decaohm: prefix!(deca); "daΩ", "decaohm", "decaohms";
        /// Derived unit of electrical resistance.
        @ohm: prefix!(none); "Ω", "ohm", "ohms";
        @deciohm: prefix!(deci); "dΩ", "deciohm", "deciohms";
        @centiohm: prefix!(centi); "cΩ", "centiohm", "centiohms";
        @milliohm: prefix!(milli); "mΩ", "milliohm", "milliohms";
        @microohm: prefix!(micro); "µΩ", "microohm", "microohms";
        @nanoohm: prefix!(nano); "nΩ", "nanoohm", "nanoohms";
        @picoohm: prefix!(pico); "pΩ", "picoohm", "picoohms";
        @femtoohm: prefix!(femto); "fΩ", "femtoohm", "femtoohms";
        @attoohm: prefix!(atto); "aΩ", "attoohm", "attoohms";
        @zeptoohm: prefix!(zepto); "zΩ", "zeptoohm", "zeptoohms";
        @yoctoohm: prefix!(yocto); "yΩ", "yoctoohm", "yoctoohms";

        @abohm: 1.0_E-9; "abΩ", "abohm", "abohms";
        @statohm: 8.987_552_917_115_481_E11; "statΩ", "statohm", "statohms";
    }
}

#[cfg(test)]
mod tests {
    storage_types! {
        use crate::num::One;
        use crate::si::electric_current as i;
        use crate::si::electric_potential as v;
        use crate::si::electrical_resistance as r;
        use crate::si::quantities::*;
        use crate::tests::Test;

        #[test]
        fn check_dimension() {
            let _: ElectricalResistance<V> = ElectricPotential::new::<v::volt>(V::one())
                / ElectricCurrent::new::<i::ampere>(V::one());
        }

        #[test]
        fn check_units() {
            test::<v::yottavolt, i::ampere, r::yottaohm>();
            test::<v::zettavolt, i::ampere, r::zettaohm>();
            test::<v::exavolt, i::ampere, r::exaohm>();
            test::<v::petavolt, i::ampere, r::petaohm>();
            test::<v::teravolt, i::ampere, r::teraohm>();
            test::<v::gigavolt, i::ampere, r::gigaohm>();
            test::<v::megavolt, i::ampere, r::megaohm>();
            test::<v::kilovolt, i::ampere, r::kiloohm>();
            test::<v::hectovolt, i::ampere, r::hectoohm>();
            test::<v::decavolt, i::ampere, r::decaohm>();
            test::<v::volt, i::ampere, r::ohm>();
            test::<v::decivolt, i::ampere, r::deciohm>();
            test::<v::centivolt, i::ampere, r::centiohm>();
            test::<v::millivolt, i::ampere, r::milliohm>();
            test::<v::microvolt, i::ampere, r::microohm>();
            test::<v::nanovolt, i::ampere, r::nanoohm>();
            test::<v::picovolt, i::ampere, r::picoohm>();
            test::<v::femtovolt, i::ampere, r::femtoohm>();
            test::<v::attovolt, i::ampere, r::attoohm>();
            test::<v::zeptovolt, i::ampere, r::zeptoohm>();
            test::<v::yoctovolt, i::ampere, r::yoctoohm>();

            test::<v::abvolt, i::abampere, r::abohm>();
            test::<v::statvolt, i::statampere, r::statohm>();

            fn test<U: v::Conversion<V>, I: i::Conversion<V>, R: r::Conversion<V>>() {
                Test::assert_approx_eq(&ElectricalResistance::new::<R>(V::one()),
                    &(ElectricPotential::new::<U>(V::one())
                        / ElectricCurrent::new::<I>(V::one())));
            }
        }
    }
}