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
//! Temperature coefficient (base unit 1 / kelvin, K⁻¹).

quantity! {
    /// Temperature coefficient (base unit 1 / kelvin, K⁻¹).
    quantity: TemperatureCoefficient; "temperature coefficient";
    /// Dimension of temperature coefficient, Th⁻¹ (base unit 1 / kelvin, K⁻¹).
    dimension: ISQ<
        Z0,     // length
        Z0,     // mass
        Z0,     // time
        Z0,     // electric current
        N1,     // thermodynamic temperature
        Z0,     // amount of substance
        Z0>;    // luminous intensity
    units {
        @per_kelvin: prefix!(none); "K⁻¹", "per kelvin", "per kelvin";
        @ppm_per_kelvin: 1E-6; "ppm/K", "ppm per kelvin", "ppm per kelvin";
        @ppm_per_degree_celsius: 1E-6; "ppm/°C", "ppm per degree Celsius", "ppm per degree Celsius";
    }
}

#[cfg(test)]
mod test {
    storage_types! {
        use crate::num::One;
        use crate::si::temperature_interval as ti;
        use crate::si::temperature_coefficient as tc;
        use crate::si::quantities::*;
        use crate::tests::Test;

        #[test]
        fn check_dimension() {
            let _: TemperatureCoefficient<V> = V::one()
                / TemperatureInterval::new::<ti::kelvin>(V::one());
        }

        #[test]
        fn check_units() {
            test::<ti::kelvin, tc::per_kelvin>();
            test::<ti::megakelvin, tc::ppm_per_kelvin>();
            test::<ti::megakelvin, tc::ppm_per_degree_celsius>();

            fn test<TI: ti::Conversion<V>, TC: tc::Conversion<V>>() {
                Test::assert_approx_eq(&TemperatureCoefficient::new::<TC>(V::one()),
                    &(V::one()
                        / TemperatureInterval::new::<TI>(V::one())));
            }
        }
    }
}