uom/si/
electric_potential.rs1quantity! {
4 quantity: ElectricPotential; "electric potential";
6 dimension: ISQ<
8 P2, P1, N3, N1, Z0, Z0, Z0>; units {
16 @yottavolt: prefix!(yotta); "YV", "yottavolt", "yottavolts";
17 @zettavolt: prefix!(zetta); "ZV", "zettavolt", "zettavolts";
18 @exavolt: prefix!(exa); "EV", "exavolt", "exavolts";
19 @petavolt: prefix!(peta); "PV", "petavolt", "petavolts";
20 @teravolt: prefix!(tera); "TV", "teravolt", "teravolts";
21 @gigavolt: prefix!(giga); "GV", "gigavolt", "gigavolts";
22 @megavolt: prefix!(mega); "MV", "megavolt", "megavolts";
23 @kilovolt: prefix!(kilo); "kV", "kilovolt", "kilovolts";
24 @hectovolt: prefix!(hecto); "hV", "hectovolt", "hectovolts";
25 @decavolt: prefix!(deca); "daV", "decavolt", "decavolts";
26 @volt: prefix!(none); "V", "volt", "volts";
28 @decivolt: prefix!(deci); "dV", "decivolt", "decivolts";
29 @centivolt: prefix!(centi); "cV", "centivolt", "centivolts";
30 @millivolt: prefix!(milli); "mV", "millivolt", "millivolts";
31 @microvolt: prefix!(micro); "µV", "microvolt", "microvolts";
32 @nanovolt: prefix!(nano); "nV", "nanovolt", "nanovolts";
33 @picovolt: prefix!(pico); "pV", "picovolt", "picovolts";
34 @femtovolt: prefix!(femto); "fV", "femtovolt", "femtovolts";
35 @attovolt: prefix!(atto); "aV", "attovolt", "attovolts";
36 @zeptovolt: prefix!(zepto); "zV", "zeptovolt", "zeptovolts";
37 @yoctovolt: prefix!(yocto); "yV", "yoctovolt", "yoctovolts";
38
39 @abvolt: 1.0_E-8; "abV", "abvolt", "abvolts";
40 @statvolt: 2.997_925_E2; "statV", "statvolt", "statvolts";
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 storage_types! {
47 use crate::num::One;
48 use crate::si::area as a;
49 use crate::si::electric_current as i;
50 use crate::si::electric_potential as v;
51 use crate::si::mass as m;
52 use crate::si::quantities::*;
53 use crate::si::time as t;
54 use crate::tests::Test;
55
56 #[test]
57 fn check_dimension() {
58 let _: ElectricPotential<V> = Area::new::<a::square_meter>(V::one())
59 * Mass::new::<m::kilogram>(V::one())
60 / (ElectricCurrent::new::<i::ampere>(V::one())
61 * (Time::new::<t::second>(V::one()) * Time::new::<t::second>(V::one())
62 * Time::new::<t::second>(V::one())));
63 }
64
65 #[test]
66 fn check_units() {
67 test::<i::yottaampere, v::yoctovolt>();
68 test::<i::zettaampere, v::zeptovolt>();
69 test::<i::exaampere, v::attovolt>();
70 test::<i::petaampere, v::femtovolt>();
71 test::<i::teraampere, v::picovolt>();
72 test::<i::gigaampere, v::nanovolt>();
73 test::<i::megaampere, v::microvolt>();
74 test::<i::kiloampere, v::millivolt>();
75 test::<i::hectoampere, v::centivolt>();
76 test::<i::decaampere, v::decivolt>();
77 test::<i::ampere, v::volt>();
78 test::<i::deciampere, v::decavolt>();
79 test::<i::centiampere, v::hectovolt>();
80 test::<i::milliampere, v::kilovolt>();
81 test::<i::microampere, v::megavolt>();
82 test::<i::nanoampere, v::gigavolt>();
83 test::<i::picoampere, v::teravolt>();
84 test::<i::femtoampere, v::petavolt>();
85 test::<i::attoampere, v::exavolt>();
86 test::<i::zeptoampere, v::zettavolt>();
87 test::<i::yoctoampere, v::yottavolt>();
88
89 fn test<I: i::Conversion<V>, E: v::Conversion<V>>() {
90 Test::assert_approx_eq(&ElectricPotential::new::<E>(V::one()),
91 &(Area::new::<a::square_meter>(V::one()) * Mass::new::<m::kilogram>(V::one())
92 / (ElectricCurrent::new::<I>(V::one())
93 * (Time::new::<t::second>(V::one()) * Time::new::<t::second>(V::one())
94 * Time::new::<t::second>(V::one())))));
95 }
96 }
97 }
98}