Skip to content

Commit a2c358e

Browse files
authored
Merge pull request #284 from SamSmithNZ-dotcom/finding-autofix-675059e1
Fix for Equality check on floating point values
2 parents da9f052 + 138b97b commit a2c358e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/MandMCounter.Tests/MandMTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void CountMandMsInAUSGallonTest()
2121
float result = Calculator.CountMandMs(unit, quantity);
2222

2323
//Assert
24-
Assert.IsTrue(System.Math.Round(result, 0) == 4047f);
24+
Assert.AreEqual(4047f, (float)System.Math.Round(result, 0), 0.1f);
2525
}
2626

2727
[TestMethod]
@@ -35,7 +35,7 @@ public void CountMandMsInAUSQuartTest()
3535
float result = Calculator.CountMandMs(unit, quantity);
3636

3737
//Assert
38-
Assert.IsTrue(System.Math.Round(result, 0) == 1012f);
38+
Assert.AreEqual(1012f, (float)System.Math.Round(result, 0), 0.1f);
3939
}
4040

4141
[TestMethod]
@@ -49,7 +49,7 @@ public void CountMandMsInAUSOunceTest()
4949
float result = Calculator.CountMandMs(unit, quantity);
5050

5151
//Assert
52-
Assert.IsTrue(System.Math.Round(result, 0) == 32f);
52+
Assert.AreEqual(32f, (float)System.Math.Round(result, 0), 0.1f);
5353
}
5454

5555
[TestMethod]
@@ -63,7 +63,7 @@ public void CountMandMsIn21PoundsTest()
6363
float result = Calculator.CountMandMs(unit, quantity);
6464

6565
//Assert
66-
Assert.IsTrue(System.Math.Round(result, 0) == 339973f);
66+
Assert.AreEqual(339973f, (float)System.Math.Round(result, 0), 0.1f);
6767
}
6868

6969

@@ -78,7 +78,7 @@ public void CountMandMsInAUSCupTest()
7878
float result = Calculator.CountMandMs(unit, quantity);
7979

8080
//Assert
81-
Assert.IsTrue(System.Math.Round(result, 0) == 253f);
81+
Assert.AreEqual(253f, (float)System.Math.Round(result, 0), 0.1f);
8282
}
8383

8484

@@ -93,7 +93,7 @@ public void CountMandMsInAUSQuarterCupTest()
9393
float result = Calculator.CountMandMs(unit, quantity);
9494

9595
//Assert
96-
Assert.IsTrue(System.Math.Round(result, 0) == 63f);
96+
Assert.AreEqual(63f, (float)System.Math.Round(result, 0), 0.1f);
9797
}
9898

9999
[TestMethod]
@@ -107,7 +107,7 @@ public void CountMandMsInAUSTableSpoonTest()
107107
float result = Calculator.CountMandMs(unit, quantity);
108108

109109
//Assert
110-
Assert.IsTrue(System.Math.Round(result, 0) == 16f);
110+
Assert.AreEqual(16f, (float)System.Math.Round(result, 0), 0.1f);
111111
}
112112

113113
[TestMethod]

0 commit comments

Comments
 (0)