Added units of voltage
This commit is contained in:
parent
f03850f006
commit
6553c50d1d
@ -1,3 +1,9 @@
|
||||
## Next
|
||||
- Added units of electric current
|
||||
- Added units of voltage
|
||||
- Added units of resistance
|
||||
- Fixed interpreting of `µs`
|
||||
|
||||
## 1.1.0 - 2020 Nov 14
|
||||
- Added units of frequency
|
||||
- Added support using foot-inch syntax with addition, like `2"+6'4"`
|
||||
|
||||
@ -336,6 +336,10 @@ pub fn lex(input: &str, allow_trailing_operators: bool, default_degree: Unit) ->
|
||||
"Ω" | "Ω" | "ohm" | "ohms" => tokens.push(Token::Unit(Ohm)),
|
||||
"kΩ" | "kΩ" | "kiloohm" | "kiloohms" => tokens.push(Token::Unit(Kiloohm)),
|
||||
|
||||
"mv" | "millivolt" | "millivolts" => tokens.push(Token::Unit(Millivolt)),
|
||||
"v" | "volt" | "volts" => tokens.push(Token::Unit(Volt)),
|
||||
"kv" | "kilovolt" | "kilovolts" => tokens.push(Token::Unit(Kilovolt)),
|
||||
|
||||
// for pound-force per square inch
|
||||
"lbf" => tokens.push(Token::LexerKeyword(PoundForce)),
|
||||
"force" => tokens.push(Token::LexerKeyword(Force)),
|
||||
|
||||
@ -27,6 +27,8 @@ pub enum UnitType {
|
||||
ElectricCurrent,
|
||||
/// A unit of electric resistance, for example `Ohm`
|
||||
Resistance,
|
||||
/// A unit of voltage, for example `Volt`
|
||||
Voltage,
|
||||
/// A unit of pressure, for example `Bar`
|
||||
Pressure,
|
||||
/// A unit of frequency, for example `Hertz`
|
||||
@ -222,6 +224,10 @@ create_units!(
|
||||
Ohm: (Resistance, d128!(1000)),
|
||||
Kiloohm: (Resistance, d128!(1000000)),
|
||||
|
||||
Millivolt: (Voltage, d128!(1)),
|
||||
Volt: (Voltage, d128!(1000)),
|
||||
Kilovolt: (Voltage, d128!(1000000)),
|
||||
|
||||
Pascal: (Pressure, d128!(1)),
|
||||
Kilopascal: (Pressure, d128!(1000)),
|
||||
Atmosphere: (Pressure, d128!(101325)),
|
||||
@ -684,6 +690,9 @@ mod tests {
|
||||
assert_eq!(convert_test(1000.0, Milliohm, Ohm), 1.0);
|
||||
assert_eq!(convert_test(1000.0, Ohm, Kiloohm), 1.0);
|
||||
|
||||
assert_eq!(convert_test(1000.0, Millivolt, Volt), 1.0);
|
||||
assert_eq!(convert_test(1000.0, Volt, Kilovolt), 1.0);
|
||||
|
||||
assert_eq!(convert_test(1000.0, Pascal, Kilopascal), 1.0);
|
||||
assert_eq!(convert_test(101325.0, Pascal, Atmosphere), 1.0);
|
||||
assert_eq!(convert_test(100.0, Pascal, Millibar), 1.0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user