Skip to content

Commit 24715d3

Browse files
CPMOliveiraangularsen
authored andcommitted
Add Length.Hectometer, Volume.CubicHectometer (#638)
Add Length.Hecto prefix Add Volume.CubicHectometer Modify the test Assert.Equal with addition of InvariantInfo, because when you compare string in cultures like Brazilian Portuguese (the decimal separator is comma) the test fail.
1 parent 1edfef9 commit 24715d3

File tree

17 files changed

+114
-5
lines changed

17 files changed

+114
-5
lines changed

Common/UnitDefinitions/Length.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"FromUnitToBaseFunc": "x",
1616
"FromBaseToUnitFunc": "x",
17-
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
17+
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Hecto", "Kilo" ],
1818
"Localization": [
1919
{
2020
"Culture": "en-US",
@@ -23,7 +23,7 @@
2323
{
2424
"Culture": "ru-RU",
2525
"Abbreviations": [ "м" ],
26-
"AbbreviationsWithPrefixes": [ "нм", "мкм", "мм", "см", "дм", "км" ]
26+
"AbbreviationsWithPrefixes": [ "нм", "мкм", "мм", "см", "дм", "гм", "км" ]
2727
}
2828
]
2929
},

Common/UnitDefinitions/Volume.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Name": "Volume",
33
"BaseUnit": "CubicMeter",
44
"XmlDoc": "Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces.",
@@ -58,6 +58,25 @@
5858
]
5959
},
6060
{
61+
"SingularName": "CubicHectometer",
62+
"PluralName": "CubicHectometers",
63+
"BaseUnits": {
64+
"L": "Hectometer"
65+
},
66+
"FromUnitToBaseFunc": "x*1e6",
67+
"FromBaseToUnitFunc": "x/1e6",
68+
"Localization": [
69+
{
70+
"Culture": "en-US",
71+
"Abbreviations": [ "hm³" ]
72+
},
73+
{
74+
"Culture": "ru-RU",
75+
"Abbreviations": [ "гм³" ]
76+
}
77+
]
78+
},
79+
{
6180
"SingularName": "CubicDecimeter",
6281
"PluralName": "CubicDecimeters",
6382
"FromUnitToBaseFunc": "x/1e3",

UnitsNet.Tests/CustomCode/LengthTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class LengthTests : LengthTestsBase
2121

2222
protected override double FeetInOneMeter => 3.28084;
2323

24+
protected override double HectometersInOneMeter => 1E-2;
25+
2426
protected override double TwipsInOneMeter => 56692.913386;
2527
protected override double UsSurveyFeetInOneMeter => 3.280833333333333;
2628

UnitsNet.Tests/CustomCode/VolumeTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class VolumeTests : VolumeTestsBase
2020

2121
protected override double CubicKilometersInOneCubicMeter => 1E-9;
2222

23+
protected override double CubicHectometersInOneCubicMeter => 1E-6;
24+
2325
protected override double CubicMetersInOneCubicMeter => 1;
2426

2527
protected override double CubicMilesInOneCubicMeter => 2.399127585789277e-10;

UnitsNet.Tests/GeneratedCode/LengthTestsBase.g.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/QuantityIFormattableTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
33

44
using System;
5+
using System.Globalization;
56
using Xunit;
67

78
namespace UnitsNet.Tests
@@ -61,7 +62,7 @@ public void QFormatEqualsQuantityName()
6162
[InlineData("s6", "1.234568 ft")]
6263
public void SFormatEqualsSignificantDigits(string sFormatString, string expected)
6364
{
64-
Assert.Equal(expected, length.ToString(sFormatString));
65+
Assert.Equal(expected, length.ToString(sFormatString, NumberFormatInfo.InvariantInfo));
6566
}
6667

6768
[Fact]

UnitsNet.Tests/QuantityTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void TryParse_GivenValueAndUnit_ReturnsQuantity()
165165
Assert.True(Quantity.TryParse(typeof(Mass), "03t", out IQuantity parsedMass));
166166
Assert.Equal(Mass.FromTonnes(3), parsedMass);
167167

168-
Assert.True(Quantity.TryParse(typeof(Pressure), "3.0 Mbar", out IQuantity parsedPressure));
168+
Assert.True(Quantity.TryParse(NumberFormatInfo.InvariantInfo, typeof(Pressure), "3.0 Mbar", out IQuantity parsedPressure));
169169
Assert.Equal(Pressure.FromMegabars(3), parsedPressure);
170170
}
171171

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.WindowsRuntimeComponent.g.cs

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)