Enable PMD rule SimplifiableTestAssertion and fix violations
This commit is contained in:
parent
09a9c1a104
commit
b1a88b01ab
9 changed files with 25 additions and 30 deletions
|
@ -24,18 +24,14 @@ public class LinkedListContainerTest {
|
||||||
|
|
||||||
for (int ln = 0; ln < nlists; ln++) {
|
for (int ln = 0; ln < nlists; ln++) {
|
||||||
int cnt = llc.initList(ln);
|
int cnt = llc.initList(ln);
|
||||||
Assert.assertTrue("list size test", cnt == 20);
|
Assert.assertEquals("list size test", 20, cnt);
|
||||||
|
|
||||||
for (int i = 19; i >= 0; i--) {
|
for (int i = 19; i >= 0; i--) {
|
||||||
int data = llc.getDataElement();
|
int data = llc.getDataElement();
|
||||||
Assert.assertTrue("data value test", data == ln * (i % 10));
|
Assert.assertEquals("data value test", ln * (i % 10), data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
Assert.assertThrows("no more elements expected", IllegalArgumentException.class, () -> llc.getDataElement());
|
||||||
llc.getDataElement();
|
|
||||||
Assert.fail("no more elements expected");
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class MapcreatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void mapcreatorTest() throws Exception {
|
public void mapcreatorTest() throws Exception {
|
||||||
URL mapurl = this.getClass().getResource("/dreieich.osm.gz");
|
URL mapurl = this.getClass().getResource("/dreieich.osm.gz");
|
||||||
Assert.assertTrue("test-osm-map dreieich.osm not found", mapurl != null);
|
Assert.assertNotNull("test-osm-map dreieich.osm not found", mapurl);
|
||||||
File mapFile = new File(mapurl.getFile());
|
File mapFile = new File(mapurl.getFile());
|
||||||
File workingDir = mapFile.getParentFile();
|
File workingDir = mapFile.getParentFile();
|
||||||
File profileDir = new File(workingDir, "/../../../../misc/profiles2");
|
File profileDir = new File(workingDir, "/../../../../misc/profiles2");
|
||||||
|
|
|
@ -20,11 +20,11 @@ public class BitCoderContextTest {
|
||||||
for (int i = 0; i < 31; i++) {
|
for (int i = 0; i < 31; i++) {
|
||||||
int value = ctx.decodeVarBits();
|
int value = ctx.decodeVarBits();
|
||||||
int v0 = (1 << i) + 3;
|
int v0 = (1 << i) + 3;
|
||||||
Assert.assertTrue("value mismatch value=" + value + "v0=" + v0, v0 == value);
|
Assert.assertEquals("value mismatch value=" + value + "v0=" + v0, v0, value);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 100000; i += 13) {
|
for (int i = 0; i < 100000; i += 13) {
|
||||||
int value = ctx.decodeVarBits();
|
int value = ctx.decodeVarBits();
|
||||||
Assert.assertTrue("value mismatch i=" + i + "v=" + value, value == i);
|
Assert.assertEquals("value mismatch i=" + i + "v=" + value, value, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class ByteDataIOTest {
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
int value = r.readVarLengthUnsigned();
|
int value = r.readVarLengthUnsigned();
|
||||||
Assert.assertTrue("value mismatch", value == i);
|
Assert.assertEquals("value mismatch", value, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package btools.util;
|
package btools.util;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class CompactMapTest {
|
public class CompactMapTest {
|
||||||
@Test
|
@Test
|
||||||
public void hashMapComparisonTest() {
|
public void hashMapComparisonTest() {
|
||||||
|
@ -48,8 +48,8 @@ public class CompactMapTest {
|
||||||
String s = hmap.get(KK);
|
String s = hmap.get(KK);
|
||||||
|
|
||||||
boolean contained = hmap.containsKey(KK);
|
boolean contained = hmap.containsKey(KK);
|
||||||
Assert.assertTrue("containsKey missmatch (slow)", contained == cmap_slow.contains(k));
|
Assert.assertEquals("containsKey missmatch (slow)", contained, cmap_slow.contains(k));
|
||||||
Assert.assertTrue("containsKey missmatch (fast)", contained == cmap_fast.contains(k));
|
Assert.assertEquals("containsKey missmatch (fast)", contained, cmap_fast.contains(k));
|
||||||
|
|
||||||
if (contained) {
|
if (contained) {
|
||||||
Assert.assertEquals("object missmatch (fast)", s, cmap_fast.get(k));
|
Assert.assertEquals("object missmatch (fast)", s, cmap_fast.get(k));
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package btools.util;
|
package btools.util;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class CompactSetTest {
|
public class CompactSetTest {
|
||||||
@Test
|
@Test
|
||||||
public void hashSetComparisonTest() {
|
public void hashSetComparisonTest() {
|
||||||
|
@ -46,8 +46,8 @@ public class CompactSetTest {
|
||||||
Long KK = new Long(k);
|
Long KK = new Long(k);
|
||||||
|
|
||||||
boolean contained = hset.contains(KK);
|
boolean contained = hset.contains(KK);
|
||||||
Assert.assertTrue("contains missmatch (slow)", contained == cset_slow.contains(k));
|
Assert.assertEquals("contains missmatch (slow)", contained, cset_slow.contains(k));
|
||||||
Assert.assertTrue("contains missmatch (fast)", contained == cset_fast.contains(k));
|
Assert.assertEquals("contains missmatch (fast)", contained, cset_fast.contains(k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package btools.util;
|
package btools.util;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class DenseLongMapTest {
|
public class DenseLongMapTest {
|
||||||
@Test
|
@Test
|
||||||
public void hashMapComparisonTest() {
|
public void hashMapComparisonTest() {
|
||||||
|
@ -94,7 +94,7 @@ public class DenseLongMapTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to use the map again for valid memory measure
|
// need to use the map again for valid memory measure
|
||||||
Assert.assertTrue("out of range test", dmap.getInt(-1) == -1);
|
Assert.assertEquals("out of range test", -1, dmap.getInt(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class SortedHeapTest {
|
||||||
Assert.assertTrue("sorting test", val >= lastval);
|
Assert.assertTrue("sorting test", val >= lastval);
|
||||||
lastval = val;
|
lastval = val;
|
||||||
}
|
}
|
||||||
Assert.assertTrue("total count test", cnt == 100000);
|
Assert.assertEquals("total count test", 100000, cnt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ public class SortedHeapTest {
|
||||||
if (s == null) break;
|
if (s == null) break;
|
||||||
cnt++;
|
cnt++;
|
||||||
int val = Integer.parseInt(s);
|
int val = Integer.parseInt(s);
|
||||||
Assert.assertTrue("sequence test", val == expected);
|
Assert.assertEquals("sequence test", val, expected);
|
||||||
expected++;
|
expected++;
|
||||||
}
|
}
|
||||||
Assert.assertTrue("total count test", cnt == 100000);
|
Assert.assertEquals("total count test", 100000, cnt);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
<exclude name="PreserveStackTrace" />
|
<exclude name="PreserveStackTrace" />
|
||||||
<exclude name="PrimitiveWrapperInstantiation" />
|
<exclude name="PrimitiveWrapperInstantiation" />
|
||||||
<exclude name="ReturnEmptyCollectionRatherThanNull" />
|
<exclude name="ReturnEmptyCollectionRatherThanNull" />
|
||||||
<exclude name="SimplifiableTestAssertion" />
|
|
||||||
<exclude name="SimplifyBooleanReturns" />
|
<exclude name="SimplifyBooleanReturns" />
|
||||||
<exclude name="UncommentedEmptyConstructor" />
|
<exclude name="UncommentedEmptyConstructor" />
|
||||||
<exclude name="UncommentedEmptyMethodBody" />
|
<exclude name="UncommentedEmptyMethodBody" />
|
||||||
|
|
Loading…
Reference in a new issue