This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git


The following commit(s) were added to refs/heads/master by this push:
     new 44cacbc  Fix SonarCloud: Use assert NotEquals/NotSame/Equals
44cacbc is described below

commit 44cacbccb933925ae42c9284ca493e0a5f8fc50c
Author: aherbert <aherb...@apache.org>
AuthorDate: Tue Jun 30 15:59:05 2020 +0100

    Fix SonarCloud: Use assert NotEquals/NotSame/Equals
---
 .../apache/commons/rng/core/ProvidersCommonParametricTest.java |  8 ++++----
 .../rng/sampling/distribution/PoissonSamplerCacheTest.java     |  2 +-
 .../commons/rng/simple/ProvidersCommonParametricTest.java      | 10 +++++-----
 .../test/java/org/apache/commons/rng/simple/RandomAssert.java  |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git 
a/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
 
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
index 98e0dc0..071e6b6 100644
--- 
a/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
+++ 
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersCommonParametricTest.java
@@ -234,15 +234,15 @@ public class ProvidersCommonParametricTest {
         final List<Number> listOrig = makeList(n);
         // Discard a few more.
         final List<Number> listDiscard = makeList(n);
-        Assert.assertTrue(listDiscard.size() != 0);
-        Assert.assertFalse(listOrig.equals(listDiscard));
+        Assert.assertNotEquals(0, listDiscard.size());
+        Assert.assertNotEquals(listOrig, listDiscard);
         // Reset.
         generator.restoreState(state);
         // Replay.
         final List<Number> listReplay = makeList(n);
-        Assert.assertFalse(listOrig == listReplay);
+        Assert.assertNotSame(listOrig, listReplay);
         // Check that the restored state is the same as the original.
-        Assert.assertTrue(listOrig.equals(listReplay));
+        Assert.assertEquals(listOrig, listReplay);
     }
 
     @Test(expected = IllegalStateException.class)
diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
index 5f0d753..a5cddd5 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/PoissonSamplerCacheTest.java
@@ -472,7 +472,7 @@ public class PoissonSamplerCacheTest {
         }
 
         final PoissonSamplerCache cache2 = cache.withRange(minMean2, maxMean2);
-        Assert.assertTrue("WithRange cache is the same object", cache != 
cache2);
+        Assert.assertNotSame("WithRange cache is the same object", cache, 
cache2);
 
         // Test all means in the test range (which may be different
         // from the cache range).
diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
index fd7da1c..76b3ba9 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
@@ -223,25 +223,25 @@ public class ProvidersCommonParametricTest {
 
         // Discard a few more.
         final List<Number> listDiscard = makeList(n);
-        Assert.assertTrue(listDiscard.size() != 0);
-        Assert.assertFalse(listOrig.equals(listDiscard));
+        Assert.assertNotEquals(0, listDiscard.size());
+        Assert.assertNotEquals(listOrig, listDiscard);
 
         // Retrieve from serialized stream.
         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
         ObjectInputStream ois = new ObjectInputStream(bis);
         final RandomProviderState stateNew = new 
RandomProviderDefaultState((byte[]) ois.readObject());
 
-        Assert.assertTrue(stateOrig != stateNew);
+        Assert.assertNotSame(stateOrig, stateNew);
 
         // Reset.
         restorable.restoreState(stateNew);
 
         // Replay.
         final List<Number> listReplay = makeList(n);
-        Assert.assertFalse(listOrig == listReplay);
+        Assert.assertNotSame(listOrig, listReplay);
 
         // Check that the serialized data recreated the orginal state.
-        Assert.assertTrue(listOrig.equals(listReplay));
+        Assert.assertEquals(listOrig, listReplay);
     }
 
     @Test
diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/RandomAssert.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/RandomAssert.java
index 3b09753..a590279 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/RandomAssert.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/RandomAssert.java
@@ -38,7 +38,7 @@ public final class RandomAssert {
     public static void assertProduceSameSequence(UniformRandomProvider rng1,
                                                  UniformRandomProvider rng2) {
         for (int i = 0; i < 54; i++) {
-            Assert.assertTrue(rng1.nextBoolean() == rng2.nextBoolean());
+            Assert.assertEquals(rng1.nextBoolean(), rng2.nextBoolean());
         }
         for (int i = 0; i < 23; i++) {
             Assert.assertEquals(rng1.nextInt(), rng2.nextInt());

Reply via email to