You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/10/21 17:36:11 UTC

[GitHub] [commons-math] aherbert commented on a diff in pull request #223: Simplify assertion same result but simplest.

aherbert commented on code in PR #223:
URL: https://github.com/apache/commons-math/pull/223#discussion_r1002033336


##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java:
##########
@@ -259,7 +259,7 @@ public void testEqualsAndHashCode() {
         int emptyHash = u.hashCode();
         Assert.assertEquals(u, u);
         Assert.assertNotEquals(u, t);
-        Assert.assertFalse(u.equals(Double.valueOf(0)));
+        Assert.assertNotEquals(u, Double.valueOf(0), 0.0);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java:
##########
@@ -167,7 +167,7 @@ public void testEqualsAndHashCode() {
         BigReal nullReal = null;
         Assert.assertEquals(zero, zero);
         Assert.assertNotEquals(zero, nullReal);
-        Assert.assertFalse(zero.equals(Double.valueOf(0)));
+        Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);

Review Comment:
   This is testing the `equals()` method. Please revert.



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java:
##########
@@ -452,11 +452,11 @@ public void testEqualsAndHashCode() throws Exception {
         // Wrong type
         ResizableDoubleArray first = new ResizableDoubleArray();
         Double other = Double.valueOf(2);
-        Assert.assertFalse(first.equals(other));

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java:
##########
@@ -452,11 +452,11 @@ public void testEqualsAndHashCode() throws Exception {
         // Wrong type
         ResizableDoubleArray first = new ResizableDoubleArray();
         Double other = Double.valueOf(2);
-        Assert.assertFalse(first.equals(other));
+        Assert.assertNotEquals(first, other, 0.0);
 
         // Null
         other = null;
-        Assert.assertFalse(first.equals(other));

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java:
##########
@@ -124,8 +124,8 @@ public void testCopyConsistencyWithInitialFirstFewElements() {
                 (int) (testArray.length - index));
         // Check same
         // Explicit test of the equals method
-        Assert.assertTrue(master.equals(master));
-        Assert.assertTrue(replica.equals(replica));
+        Assert.assertEquals(master, master);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java:
##########
@@ -161,7 +161,7 @@ public void testEqualsAndHashCode() {
         int emptyHash = u.hashCode();
         Assert.assertEquals("reflexive", u, u);
         Assert.assertNotEquals("non-null compared to null", u, t);
-        Assert.assertFalse("wrong type", u.equals(Double.valueOf(0)));
+        Assert.assertNotEquals("wrong type", u, Double.valueOf(0), 0.0);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java:
##########
@@ -80,7 +80,7 @@ public void testEqualsAndHashCode() {
             (StorelessUnivariateStatistic) getUnivariateStatistic();
         StorelessUnivariateStatistic statistic2 = null;
 
-        Assert.assertFalse("non-null, compared to null", statistic.equals(statistic2));
+        Assert.assertNotEquals("non-null, compared to null", statistic, statistic2);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/NeuronTest.java:
##########
@@ -92,7 +92,7 @@ public void testCopy() {
         final Neuron copy = n.copy();
 
         // Check that original and copy have the same value.
-        Assert.assertTrue(n.getFeatures()[0] == copy.getFeatures()[0]);
+        Assert.assertEquals(n.getFeatures()[0], copy.getFeatures()[0], 0.0);

Review Comment:
   No delta required when delta==0.0



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java:
##########
@@ -281,15 +281,15 @@ public void testEqualsAndHashCode() {
         t.addValue(new double[] { 3d, 1d });
         t.addValue(new double[] { 4d, 1d });
         t.addValue(new double[] { 5d, 1d });
-        Assert.assertTrue(t.equals(u));
-        Assert.assertTrue(u.equals(t));
+        Assert.assertEquals(t, u);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java:
##########
@@ -281,15 +281,15 @@ public void testEqualsAndHashCode() {
         t.addValue(new double[] { 3d, 1d });
         t.addValue(new double[] { 4d, 1d });
         t.addValue(new double[] { 5d, 1d });
-        Assert.assertTrue(t.equals(u));
-        Assert.assertTrue(u.equals(t));
+        Assert.assertEquals(t, u);
+        Assert.assertEquals(u, t);
         Assert.assertEquals(u.hashCode(), t.hashCode());
 
         // Clear and make sure summaries are indistinguishable from empty summary
         u.clear();
         t.clear();
-        Assert.assertTrue(t.equals(u));
-        Assert.assertTrue(u.equals(t));
+        Assert.assertEquals(t, u);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java:
##########
@@ -271,8 +271,8 @@ public void testEqualsAndHashCode() {
         u.addValue(new double[] { 3d, 1d });
         u.addValue(new double[] { 4d, 1d });
         u.addValue(new double[] { 5d, 1d });
-        Assert.assertFalse(t.equals(u));
-        Assert.assertFalse(u.equals(t));
+        Assert.assertNotEquals(t, u);

Review Comment:
   This is testing `equals()`, please revert



##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StatisticalSummaryValuesTest.java:
##########
@@ -35,7 +35,7 @@ public void testEqualsAndHashCode() {
         StatisticalSummaryValues t = null;
         Assert.assertEquals("reflexive", u, u);
         Assert.assertNotEquals("non-null compared to null", u, t);
-        Assert.assertFalse("wrong type", u.equals(Double.valueOf(0)));
+        Assert.assertNotEquals("wrong type", u, Double.valueOf(0), 0.0);

Review Comment:
   This is testing `equals()`, please revert



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org