Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions UnitsNet.Tests/UnitSystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,64 @@ public string ScientificNotationUpperIntervalFormatting(double value)
return Length.FromMeters(value).ToString();
}

[Test]
public void ShouldUseCorrectMicroSign()
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice set of tests this, even though it will get out of date at some point it is a nice sanity check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, it would have been ideal to tap into the code generation and have this test generated for each unit that uses the Micro symbol. The amount I have to contribute to this is dictated by the return on investment for my client though...so that extra level didn't quite make the cut (yet) unfortunately.

// "\u00b5" = Micro sign
Assert.AreEqual(AccelerationUnit.MicrometerPerSecondSquared, Acceleration.ParseUnit("\u00b5m/s²"));
Assert.AreEqual(AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatio.ParseUnit("dB\u00b5V"));
Assert.AreEqual(AngleUnit.Microdegree, Angle.ParseUnit("\u00b5°"));
Assert.AreEqual(AngleUnit.Microradian, Angle.ParseUnit("\u00b5rad"));
Assert.AreEqual(AreaUnit.SquareMicrometer, Area.ParseUnit("\u00b5m²"));
Assert.AreEqual(DurationUnit.Microsecond, Duration.ParseUnit("\u00b5s"));
Assert.AreEqual(ElectricCurrentUnit.Microampere, ElectricCurrent.ParseUnit("\u00b5A"));
Assert.AreEqual(ElectricPotentialUnit.Microvolt, ElectricPotential.ParseUnit("\u00b5V"));
Assert.AreEqual(FlowUnit.MicrolitersPerMinute, Flow.ParseUnit("\u00b5LPM"));
Assert.AreEqual(ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRate.ParseUnit("\u00b5N/s"));
Assert.AreEqual(ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLength.ParseUnit("\u00b5N/m"));
Assert.AreEqual(KinematicViscosityUnit.Microstokes, KinematicViscosity.ParseUnit("\u00b5St"));
Assert.AreEqual(LengthUnit.Microinch, Length.ParseUnit("\u00b5in"));
Assert.AreEqual(LengthUnit.Micrometer, Length.ParseUnit("\u00b5m"));
Assert.AreEqual(MassFlowUnit.MicrogramPerSecond, MassFlow.ParseUnit("\u00b5g/S"));
Assert.AreEqual(MassUnit.Microgram, Mass.ParseUnit("\u00b5g"));
Assert.AreEqual(PowerUnit.Microwatt, Power.ParseUnit("\u00b5W"));
Assert.AreEqual(PressureUnit.Micropascal, Pressure.ParseUnit("\u00b5Pa"));
Assert.AreEqual(RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeed.ParseUnit("\u00b5°/s"));
Assert.AreEqual(RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeed.ParseUnit("\u00b5rad/s"));
Assert.AreEqual(SpeedUnit.MicrometerPerMinute, Speed.ParseUnit("\u00b5m/min"));
Assert.AreEqual(SpeedUnit.MicrometerPerSecond, Speed.ParseUnit("\u00b5m/s"));
Assert.AreEqual(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRate.ParseUnit("\u00b5°C/s"));
Assert.AreEqual(VolumeUnit.Microliter, Volume.ParseUnit("\u00b5l"));
Assert.AreEqual(VolumeUnit.CubicMicrometer, Volume.ParseUnit("\u00b5m³"));

// "\u03bc" = Lower case greek letter 'Mu'
Assert.Throws<UnitsNetException>(() => Acceleration.ParseUnit("\u03bcm/s²"));
Assert.Throws<UnitsNetException>(() => AmplitudeRatio.ParseUnit("dB\u03bcV"));
Assert.Throws<UnitsNetException>(() => Angle.ParseUnit("\u03bc°"));
Assert.Throws<UnitsNetException>(() => Angle.ParseUnit("\u03bcrad"));
Assert.Throws<UnitsNetException>(() => Area.ParseUnit("\u03bcm²"));
Assert.Throws<UnitsNetException>(() => Duration.ParseUnit("\u03bcs"));
Assert.Throws<UnitsNetException>(() => ElectricCurrent.ParseUnit("\u03bcA"));
Assert.Throws<UnitsNetException>(() => ElectricPotential.ParseUnit("\u03bcV"));
Assert.Throws<UnitsNetException>(() => Flow.ParseUnit("\u03bcLPM"));
Assert.Throws<UnitsNetException>(() => ForceChangeRate.ParseUnit("\u03bcN/s"));
Assert.Throws<UnitsNetException>(() => ForcePerLength.ParseUnit("\u03bcN/m"));
Assert.Throws<UnitsNetException>(() => KinematicViscosity.ParseUnit("\u03bcSt"));
Assert.Throws<UnitsNetException>(() => Length.ParseUnit("\u03bcin"));
Assert.Throws<UnitsNetException>(() => Length.ParseUnit("\u03bcm"));
Assert.Throws<UnitsNetException>(() => MassFlow.ParseUnit("\u03bcg/S"));
Assert.Throws<UnitsNetException>(() => Mass.ParseUnit("\u03bcg"));
Assert.Throws<UnitsNetException>(() => Power.ParseUnit("\u03bcW"));
Assert.Throws<UnitsNetException>(() => Pressure.ParseUnit("\u03bcPa"));
Assert.Throws<UnitsNetException>(() => RotationalSpeed.ParseUnit("\u03bc°/s"));
Assert.Throws<UnitsNetException>(() => RotationalSpeed.ParseUnit("\u03bcrad/s"));
Assert.Throws<UnitsNetException>(() => Speed.ParseUnit("\u03bcm/min"));
Assert.Throws<UnitsNetException>(() => Speed.ParseUnit("\u03bcm/s"));
Assert.Throws<UnitsNetException>(() => TemperatureChangeRate.ParseUnit("\u03bc°C/s"));
Assert.Throws<UnitsNetException>(() => Volume.ParseUnit("\u03bcl"));
Assert.Throws<UnitsNetException>(() => Volume.ParseUnit("\u03bcm³"));
}

[Test]
public void AllUnitAbbreviationsImplemented([Values("en-US", "nb-NO", "ru-RU")] string cultureName)
{
Expand Down
2 changes: 1 addition & 1 deletion UnitsNet/GeneratedCode/UnitClasses/VitaminA.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
namespace UnitsNet
{
/// <summary>
/// Vitamin A: 1 IU is the biological equivalent of 0.3 μg retinol, or of 0.6 μg beta-carotene.
/// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.
/// </summary>
// ReSharper disable once PartialTypeWithSinglePart
#if WINDOWS_UWP
Expand Down
52 changes: 26 additions & 26 deletions UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) AccelerationUnit.MicrometerPerSecondSquared,
new[]
{
new AbbreviationsForCulture("en-US", "μm/s²"),
new AbbreviationsForCulture("en-US", "µm/s²"),
}),
new CulturesForEnumValue((int) AccelerationUnit.MillimeterPerSecondSquared,
new[]
Expand Down Expand Up @@ -154,14 +154,14 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) AngleUnit.Microdegree,
new[]
{
new AbbreviationsForCulture("en-US", "μ°"),
new AbbreviationsForCulture("ru-RU", "μ°"),
new AbbreviationsForCulture("en-US", "µ°"),
new AbbreviationsForCulture("ru-RU", "µ°"),
}),
new CulturesForEnumValue((int) AngleUnit.Microradian,
new[]
{
new AbbreviationsForCulture("en-US", "μrad"),
new AbbreviationsForCulture("ru-RU", "μрад"),
new AbbreviationsForCulture("en-US", "µrad"),
new AbbreviationsForCulture("ru-RU", "µрад"),
}),
new CulturesForEnumValue((int) AngleUnit.Millidegree,
new[]
Expand Down Expand Up @@ -472,7 +472,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) ElectricCurrentUnit.Microampere,
new[]
{
new AbbreviationsForCulture("en-US", "μA"),
new AbbreviationsForCulture("en-US", "µA"),
}),
new CulturesForEnumValue((int) ElectricCurrentUnit.Milliampere,
new[]
Expand Down Expand Up @@ -503,8 +503,8 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) ElectricPotentialUnit.Microvolt,
new[]
{
new AbbreviationsForCulture("en-US", "μV"),
new AbbreviationsForCulture("ru-RU", "μВ"),
new AbbreviationsForCulture("en-US", "µV"),
new AbbreviationsForCulture("ru-RU", "µВ"),
}),
new CulturesForEnumValue((int) ElectricPotentialUnit.Millivolt,
new[]
Expand Down Expand Up @@ -662,7 +662,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) FlowUnit.MicrolitersPerMinute,
new[]
{
new AbbreviationsForCulture("en-US", "μLPM"),
new AbbreviationsForCulture("en-US", "µLPM"),
}),
new CulturesForEnumValue((int) FlowUnit.MillilitersPerMinute,
new[]
Expand Down Expand Up @@ -773,7 +773,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) ForceChangeRateUnit.MicronewtonPerSecond,
new[]
{
new AbbreviationsForCulture("en-US", "μN/s"),
new AbbreviationsForCulture("en-US", "µN/s"),
}),
new CulturesForEnumValue((int) ForceChangeRateUnit.MillinewtonPerSecond,
new[]
Expand Down Expand Up @@ -823,7 +823,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) ForcePerLengthUnit.MicronewtonPerMeter,
new[]
{
new AbbreviationsForCulture("en-US", "μN/m"),
new AbbreviationsForCulture("en-US", "µN/m"),
}),
new CulturesForEnumValue((int) ForcePerLengthUnit.MillinewtonPerMeter,
new[]
Expand Down Expand Up @@ -1043,7 +1043,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) KinematicViscosityUnit.Microstokes,
new[]
{
new AbbreviationsForCulture("en-US", "μSt"),
new AbbreviationsForCulture("en-US", "µSt"),
new AbbreviationsForCulture("ru-RU", "мкСт"),
}),
new CulturesForEnumValue((int) KinematicViscosityUnit.Millistokes,
Expand Down Expand Up @@ -1113,13 +1113,13 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) LengthUnit.Microinch,
new[]
{
new AbbreviationsForCulture("en-US", "μin"),
new AbbreviationsForCulture("en-US", "µin"),
new AbbreviationsForCulture("ru-RU", "микродюйм"),
}),
new CulturesForEnumValue((int) LengthUnit.Micrometer,
new[]
{
new AbbreviationsForCulture("en-US", "μm"),
new AbbreviationsForCulture("en-US", "µm"),
new AbbreviationsForCulture("ru-RU", "мкм"),
}),
new CulturesForEnumValue((int) LengthUnit.Mil,
Expand Down Expand Up @@ -1238,7 +1238,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) MassUnit.Microgram,
new[]
{
new AbbreviationsForCulture("en-US", "μg"),
new AbbreviationsForCulture("en-US", "µg"),
new AbbreviationsForCulture("ru-RU", "мкг"),
}),
new CulturesForEnumValue((int) MassUnit.Milligram,
Expand Down Expand Up @@ -1323,7 +1323,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) MassFlowUnit.MicrogramPerSecond,
new[]
{
new AbbreviationsForCulture("en-US", "μg/S"),
new AbbreviationsForCulture("en-US", "µg/S"),
}),
new CulturesForEnumValue((int) MassFlowUnit.MilligramPerSecond,
new[]
Expand Down Expand Up @@ -1392,7 +1392,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) PowerUnit.Microwatt,
new[]
{
new AbbreviationsForCulture("en-US", "μW"),
new AbbreviationsForCulture("en-US", "µW"),
}),
new CulturesForEnumValue((int) PowerUnit.Milliwatt,
new[]
Expand Down Expand Up @@ -1557,7 +1557,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) PressureUnit.Micropascal,
new[]
{
new AbbreviationsForCulture("en-US", "μPa"),
new AbbreviationsForCulture("en-US", "µPa"),
new AbbreviationsForCulture("ru-RU", "мкПа"),
}),
new CulturesForEnumValue((int) PressureUnit.Millibar,
Expand Down Expand Up @@ -1725,14 +1725,14 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) RotationalSpeedUnit.MicrodegreePerSecond,
new[]
{
new AbbreviationsForCulture("en-US", "μ°/s"),
new AbbreviationsForCulture("ru-RU", "μ°/с"),
new AbbreviationsForCulture("en-US", "µ°/s"),
new AbbreviationsForCulture("ru-RU", "µ°/с"),
}),
new CulturesForEnumValue((int) RotationalSpeedUnit.MicroradianPerSecond,
new[]
{
new AbbreviationsForCulture("en-US", "μrad/s"),
new AbbreviationsForCulture("ru-RU", "μрад/с"),
new AbbreviationsForCulture("en-US", "µrad/s"),
new AbbreviationsForCulture("ru-RU", "µрад/с"),
}),
new CulturesForEnumValue((int) RotationalSpeedUnit.MillidegreePerSecond,
new[]
Expand Down Expand Up @@ -1971,12 +1971,12 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) SpeedUnit.MicrometerPerMinute,
new[]
{
new AbbreviationsForCulture("en-US", "μm/min"),
new AbbreviationsForCulture("en-US", "µm/min"),
}),
new CulturesForEnumValue((int) SpeedUnit.MicrometerPerSecond,
new[]
{
new AbbreviationsForCulture("en-US", "μm/s"),
new AbbreviationsForCulture("en-US", "µm/s"),
}),
new CulturesForEnumValue((int) SpeedUnit.MilePerHour,
new[]
Expand Down Expand Up @@ -2084,7 +2084,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond,
new[]
{
new AbbreviationsForCulture("en-US", "μ°C/s"),
new AbbreviationsForCulture("en-US", "µ°C/s"),
}),
new CulturesForEnumValue((int) TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond,
new[]
Expand Down Expand Up @@ -2357,7 +2357,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
new CulturesForEnumValue((int) VolumeUnit.Microliter,
new[]
{
new AbbreviationsForCulture("en-US", "μl"),
new AbbreviationsForCulture("en-US", "µl"),
new AbbreviationsForCulture("ru-RU", "мкл"),
}),
new CulturesForEnumValue((int) VolumeUnit.Milliliter,
Expand Down
2 changes: 1 addition & 1 deletion UnitsNet/Scripts/GenerateUnits.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function Add-PrefixUnits {
"Deci" { "d", "1e-1d"; break; }
"Centi" { "c", "1e-2d"; break; }
"Milli" { "m", "1e-3d"; break; }
"Micro" { "μ", "1e-6d"; break; }
"Micro" { "µ", "1e-6d"; break; }
"Nano" { "n", "1e-9d"; break; }

# Optimization, move less frequently used prefixes to the end
Expand Down
2 changes: 1 addition & 1 deletion UnitsNet/UnitDefinitions/Flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
{
"Culture": "en-US",
"Abbreviations": [ "LPM" ],
"AbbreviationsWithPrefixes": [ "nLPM", "μLPM", "mLPM", "cLPM", "dLPM", "kLPM" ]
"AbbreviationsWithPrefixes": [ "nLPM", "µLPM", "mLPM", "cLPM", "dLPM", "kLPM" ]
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion UnitsNet/UnitDefinitions/Length.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "μin" ]
"Abbreviations": [ "µin" ]
},
{
"Culture": "ru-RU",
Expand Down
2 changes: 1 addition & 1 deletion UnitsNet/UnitDefinitions/VitaminA.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "VitaminA",
"BaseUnit": "InternationalUnit",
"XmlDoc": "Vitamin A: 1 IU is the biological equivalent of 0.3 μg retinol, or of 0.6 μg beta-carotene.",
"XmlDoc": "Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.",
"Units": [
{
"SingularName": "InternationalUnit",
Expand Down