use crate::{duration::Duration, energy::Energy, prelude::*};
#[quantity(Energy / Duration)]
#[ref_unit(Watt, "W", NONE, "Reference unit of quantity `Power`")]
#[unit(Milliwatt, "mW", MILLI, 0.001, "0.001·W")]
#[unit(Kilowatt, "kW", KILO, 1000, "1000·W")]
#[unit(Megawatt, "MW", MEGA, 1000000, "1000000·W")]
#[unit(Gigawatt, "GW", GIGA, 1000000000, "1000000000·W")]
#[unit(Terawatt, "TW", TERA, 1000000000000., "1000000000000·W")]
pub struct Power {}
#[cfg(test)]
mod tests {
use super::*;
use crate::{assert_almost_eq, duration::MINUTE, energy::KILOWATT_HOUR};
#[test]
fn test_energy_div_duration() {
let ae: AmountT = Amnt!(90.3);
let e = ae * KILOWATT_HOUR;
let at: AmountT = Amnt!(30.);
let t = at * MINUTE;
let p = e / t;
assert_almost_eq!(p.amount(), ae / at * Amnt!(60.));
assert_eq!(p.unit(), KILOWATT);
}
}