From ff504ebc6d63b3e937a4537736ebaf69fbf46b75 Mon Sep 17 00:00:00 2001 From: PesBandi <127593627+PesBandi@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:53:07 +0200 Subject: [PATCH 1/2] Add nmi as an abbreviation for nautical miles --- Common/UnitDefinitions/Length.json | 2 +- .../TestsBase/LengthTestsBase.g.cs | 24 +++++++++++++++++++ .../GeneratedCode/Resources/Length.restext | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json index 890f55f948..3481cf8332 100644 --- a/Common/UnitDefinitions/Length.json +++ b/Common/UnitDefinitions/Length.json @@ -179,7 +179,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "NM" ] + "Abbreviations": [ "NM", "nmi" ] }, { "Culture": "ru-RU", diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 36d93c3926..ff4b28456f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -1140,6 +1140,13 @@ public void Parse() Assert.Equal(LengthUnit.NauticalMile, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = Length.Parse("1 nmi", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.NauticalMiles, NauticalMilesTolerance); + Assert.Equal(LengthUnit.NauticalMile, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = Length.Parse("1 мил", CultureInfo.GetCultureInfo("ru-RU")); @@ -1646,6 +1653,12 @@ public void TryParse() Assert.Equal(LengthUnit.Nanometer, parsed.Unit); } + { + Assert.True(Length.TryParse("1 nmi", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.NauticalMiles, NauticalMilesTolerance); + Assert.Equal(LengthUnit.NauticalMile, parsed.Unit); + } + { Assert.True(Length.TryParse("1 pc", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.Parsecs, ParsecsTolerance); @@ -2197,6 +2210,12 @@ public void ParseUnit() Assert.Equal(LengthUnit.NauticalMile, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = Length.ParseUnit("nmi", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(LengthUnit.NauticalMile, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = Length.ParseUnit("мил", CultureInfo.GetCultureInfo("ru-RU")); @@ -2622,6 +2641,11 @@ public void TryParseUnit() Assert.Equal(LengthUnit.Nanometer, parsedUnit); } + { + Assert.True(Length.TryParseUnit("nmi", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(LengthUnit.NauticalMile, parsedUnit); + } + { Assert.True(Length.TryParseUnit("pc", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(LengthUnit.Parsec, parsedUnit); diff --git a/UnitsNet/GeneratedCode/Resources/Length.restext b/UnitsNet/GeneratedCode/Resources/Length.restext index 3a1cc54758..2980054db3 100644 --- a/UnitsNet/GeneratedCode/Resources/Length.restext +++ b/UnitsNet/GeneratedCode/Resources/Length.restext @@ -30,7 +30,7 @@ Mils=mil Miles=mi Millimeters=mm Nanometers=nm -NauticalMiles=NM +NauticalMiles=NM,nmi Parsecs=pc Picometers=pm PrinterPicas=pica From d8d49305005fd3f242ecfed1234710a8a7be5442 Mon Sep 17 00:00:00 2001 From: PesBandi <127593627+PesBandi@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:53:54 +0200 Subject: [PATCH 2/2] Fix turbidity formatting --- Common/UnitDefinitions/Turbidity.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/UnitDefinitions/Turbidity.json b/Common/UnitDefinitions/Turbidity.json index 0fd0b96e72..0bcfeaad03 100644 --- a/Common/UnitDefinitions/Turbidity.json +++ b/Common/UnitDefinitions/Turbidity.json @@ -12,7 +12,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": ["NTU"] + "Abbreviations": [ "NTU" ] } ] }