Change terminology weight → mass

This commit is contained in:
Juhani Krekelä 2023-06-01 03:00:10 +03:00
parent db674d1419
commit 4eb55ac7b8
4 changed files with 7 additions and 7 deletions

View File

@ -48,7 +48,7 @@ fn get_conversion(unit: NonMetric) -> Conversion {
from: inch_from, from: inch_from,
to: MetricQuantity { amount: 1760.0 * 3.0 * 12.0 * inch_to, unit: Metric::Metre }, to: MetricQuantity { amount: 1760.0 * 3.0 * 12.0 * inch_to, unit: Metric::Metre },
}, },
// Weight // Mass
NonMetric::Ounce => Conversion { NonMetric::Ounce => Conversion {
offset: 0.0, offset: 0.0,
from: 16.0 * pound_from, from: 16.0 * pound_from,
@ -189,7 +189,7 @@ mod test {
} }
#[test] #[test]
fn weight() { fn mass() {
let tests = [ let tests = [
Test(NonMetric::Ounce, 28.349523125), Test(NonMetric::Ounce, 28.349523125),
Test(NonMetric::Pound, 453.59237), Test(NonMetric::Pound, 453.59237),

View File

@ -73,7 +73,7 @@ fn unit_to_name(unit: NonMetric) -> &'static str {
NonMetric::Foot => "feet", NonMetric::Foot => "feet",
NonMetric::Yard => "yards", NonMetric::Yard => "yards",
NonMetric::Mile => "miles", NonMetric::Mile => "miles",
// Weight // Mass
NonMetric::Ounce => "ounces", NonMetric::Ounce => "ounces",
NonMetric::Pound => "pounds", NonMetric::Pound => "pounds",
NonMetric::Stone => "stones", NonMetric::Stone => "stones",
@ -127,7 +127,7 @@ mod test {
assert_eq!(run("1 ft"), Ok("30.48 cm".to_string())); assert_eq!(run("1 ft"), Ok("30.48 cm".to_string()));
assert_eq!(run("1 yard"), Ok("91.44 cm".to_string())); assert_eq!(run("1 yard"), Ok("91.44 cm".to_string()));
assert_eq!(run("1 mile"), Ok("1.609 km".to_string())); assert_eq!(run("1 mile"), Ok("1.609 km".to_string()));
// Weight // Mass
assert_eq!(run("1 oz"), Ok("28.35 g".to_string())); assert_eq!(run("1 oz"), Ok("28.35 g".to_string()));
assert_eq!(run("1 lb"), Ok("453.6 g".to_string())); assert_eq!(run("1 lb"), Ok("453.6 g".to_string()));
assert_eq!(run("1 st"), Ok("6.35 kg".to_string())); assert_eq!(run("1 st"), Ok("6.35 kg".to_string()));

View File

@ -83,7 +83,7 @@ fn parse_unit(input: String) -> Result<NonMetric, ParseError> {
"mi" => Ok(NonMetric::Mile), "mi" => Ok(NonMetric::Mile),
"m" => Ok(NonMetric::Mile), "m" => Ok(NonMetric::Mile),
// Weight // Mass
"ounce" => Ok(NonMetric::Ounce), "ounce" => Ok(NonMetric::Ounce),
"ounces" => Ok(NonMetric::Ounce), "ounces" => Ok(NonMetric::Ounce),
"oz" => Ok(NonMetric::Ounce), "oz" => Ok(NonMetric::Ounce),
@ -459,7 +459,7 @@ mod test {
"m", "m",
]); ]);
// Weight // Mass
test_units(NonMetric::Ounce, &[ test_units(NonMetric::Ounce, &[
"ounce", "ounce",
"ounces", "ounces",

View File

@ -15,7 +15,7 @@ pub enum NonMetric {
Foot, Foot,
Yard, Yard,
Mile, Mile,
// Weight // Mass
Ounce, Ounce,
Pound, Pound,
Stone, Stone,