mirror of https://github.com/rm-dr/daisy
Minor edits
parent
356a3c7824
commit
102e619d1a
1
TODO.md
1
TODO.md
|
@ -11,6 +11,7 @@ Roadmap for fixes and features.
|
||||||
- Plural unit names
|
- Plural unit names
|
||||||
- Releases
|
- Releases
|
||||||
- Unit substitutions
|
- Unit substitutions
|
||||||
|
- mpg and gal replacement
|
||||||
|
|
||||||
## General
|
## General
|
||||||
- CLI Options: version, help, evaluate
|
- CLI Options: version, help, evaluate
|
||||||
|
|
|
@ -40,6 +40,7 @@ pub enum UnitBase {
|
||||||
Barn,
|
Barn,
|
||||||
Hectare,
|
Hectare,
|
||||||
MilesPerHour,
|
MilesPerHour,
|
||||||
|
MilesPerGallon,
|
||||||
Acre,
|
Acre,
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,6 +191,7 @@ macro_rules! fromstring_db {
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
(UnitBase::MilesPerHour, "mph"),
|
(UnitBase::MilesPerHour, "mph"),
|
||||||
|
(UnitBase::MilesPerGallon, "mpg"),
|
||||||
(UnitBase::Barn, "b"),
|
(UnitBase::Barn, "b"),
|
||||||
(UnitBase::Barn, "barn"),
|
(UnitBase::Barn, "barn"),
|
||||||
(UnitBase::Hectare, "ha"),
|
(UnitBase::Hectare, "ha"),
|
||||||
|
@ -459,11 +461,17 @@ macro_rules! unit_db {
|
||||||
// Misc
|
// Misc
|
||||||
UnitBase::MilesPerHour => $X!(
|
UnitBase::MilesPerHour => $X!(
|
||||||
UnitBase::MilesPerHour, "mph",
|
UnitBase::MilesPerHour, "mph",
|
||||||
rational, "1609.344",
|
float, "0.44704",
|
||||||
(UnitBase::Meter, 1f64),
|
(UnitBase::Meter, 1f64),
|
||||||
(UnitBase::Second, -1f64)
|
(UnitBase::Second, -1f64)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
UnitBase::MilesPerGallon => $X!(
|
||||||
|
UnitBase::MilesPerGallon, "mpg",
|
||||||
|
float, "425144",
|
||||||
|
(UnitBase::Meter, -2f64)
|
||||||
|
),
|
||||||
|
|
||||||
UnitBase::Barn => $X!(
|
UnitBase::Barn => $X!(
|
||||||
UnitBase::Barn, "b",
|
UnitBase::Barn, "b",
|
||||||
rational, "1e-28",
|
rational, "1e-28",
|
||||||
|
|
|
@ -175,7 +175,7 @@ fn operators() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn units() {
|
fn basic_units() {
|
||||||
//good_expr("4 m*s", "2 m * 2s");
|
//good_expr("4 m*s", "2 m * 2s");
|
||||||
good_expr("1 s⁻¹", "1/s");
|
good_expr("1 s⁻¹", "1/s");
|
||||||
good_expr("6 kg", "2 * 3kg");
|
good_expr("6 kg", "2 * 3kg");
|
||||||
|
@ -194,4 +194,11 @@ fn units() {
|
||||||
bad_expr("m + s");
|
bad_expr("m + s");
|
||||||
bad_expr("m ^ s");
|
bad_expr("m ^ s");
|
||||||
//bad_expr("m ^ pi");
|
//bad_expr("m ^ pi");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn complex_units() {
|
||||||
|
good_expr("0.62137 mi", "1km to mi");
|
||||||
|
good_expr("3.2808 ft", "1km to ft");
|
||||||
|
good_expr("62.137 mph", "100 km/h to mph");
|
||||||
}
|
}
|
Loading…
Reference in New Issue