Skip to content

Commit b8ef856

Browse files
authored
Inverse of Zero should return PositiveInfinity (#1540)
fixes #1535
1 parent c02b189 commit b8ef856

15 files changed

+15
-15
lines changed

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ private void GenerateRelationalOperators()
735735
/// <returns>The corresponding inverse quantity, <see cref=""{relation.RightQuantity.Name}""/>.</returns>
736736
public {relation.RightQuantity.Name} Inverse()
737737
{{
738-
return {relation.LeftUnit.PluralName} == 0.0 ? {relation.RightQuantity.Name}.Zero : {relation.RightQuantity.Name}.From{relation.RightUnit.PluralName}(1 / {relation.LeftUnit.PluralName});
738+
return {relation.RightQuantity.Name}.From{relation.RightUnit.PluralName}(1 / {relation.LeftUnit.PluralName});
739739
}}
740740
");
741741
}

UnitsNet.Tests/CustomCode/AreaTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
127127
[Theory]
128128
[InlineData(-2.0, -0.5)]
129129
[InlineData(-1.0, -1.0)]
130-
[InlineData(0.0, 0.0)]
130+
[InlineData(0.0, double.PositiveInfinity)]
131131
[InlineData(1.0, 1.0)]
132132
[InlineData(2.0, 0.5)]
133133
public void InverseReturnsReciprocalArea(double value, double expected)

UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ElectricConductivityTests : ElectricConductivityTestsBase
3939
[Theory]
4040
[InlineData( -1.0, -1.0 )]
4141
[InlineData( -2.0, -0.5 )]
42-
[InlineData( 0.0, 0.0 )]
42+
[InlineData( 0.0, double.PositiveInfinity )]
4343
[InlineData( 1.0, 1.0 )]
4444
[InlineData( 2.0, 0.5 )]
4545
public static void InverseTest( double value, double expected )

UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class ElectricResistivityTests : ElectricResistivityTestsBase
6060
[Theory]
6161
[InlineData( -1.0, -1.0 )]
6262
[InlineData( -2.0, -0.5 )]
63-
[InlineData( 0.0, 0.0 )]
63+
[InlineData( 0.0, double.PositiveInfinity )]
6464
[InlineData( 1.0, 1.0 )]
6565
[InlineData( 2.0, 0.5 )]
6666
public static void InverseTest( double value, double expected )

UnitsNet.Tests/CustomCode/LengthTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
229229
[Theory]
230230
[InlineData(-1.0, -1.0)]
231231
[InlineData(-2.0, -0.5)]
232-
[InlineData(0.0, 0.0)]
232+
[InlineData(0.0, double.PositiveInfinity)]
233233
[InlineData(1.0, 1.0)]
234234
[InlineData(2.0, 0.5)]
235235
public static void InverseReturnsReciprocalLength(double value, double expected)

UnitsNet.Tests/CustomCode/ReciprocalAreaTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ReciprocalAreaTests : ReciprocalAreaTestsBase
4040
[Theory]
4141
[InlineData(-2.0, -0.5)]
4242
[InlineData(-1.0, -1.0)]
43-
[InlineData(0.0, 0.0)]
43+
[InlineData(0.0, double.PositiveInfinity)]
4444
[InlineData(1.0, 1.0)]
4545
[InlineData(2.0, 0.5)]
4646
public void InverseReturnsArea(double value, double expected)

UnitsNet.Tests/CustomCode/ReciprocalLengthTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ReciprocalLengthTests : ReciprocalLengthTestsBase
4141
[Theory]
4242
[InlineData(-1.0, -1.0)]
4343
[InlineData(-2.0, -0.5)]
44-
[InlineData(0.0, 0.0)]
44+
[InlineData(0.0, double.PositiveInfinity)]
4545
[InlineData(1.0, 1.0)]
4646
[InlineData(2.0, 0.5)]
4747
public static void InverseReturnsLength(double value, double expected)

UnitsNet/GeneratedCode/Quantities/Area.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/Density.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/Length.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)