Skip to content

Commit 3440d16

Browse files
committed
Cleaned up the test classes
1 parent 269227c commit 3440d16

36 files changed

+47
-12
lines changed

src/com/jwetherell/algorithms/data_structures/test/AVLTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1515
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1616

17+
@SuppressWarnings("static-method")
1718
public class AVLTreeTests {
1819

1920
@Test

src/com/jwetherell/algorithms/data_structures/test/BTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class BTreeTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/BinaryHeapTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class BinaryHeapTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/BinarySearchTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class BinarySearchTreeTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/CompactSuffixTrieTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.jwetherell.algorithms.data_structures.CompactSuffixTrie;
99

10+
@SuppressWarnings("static-method")
1011
public class CompactSuffixTrieTests {
1112

1213
@Test

src/com/jwetherell/algorithms/data_structures/test/HashArrayMappedTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1212
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1313

14+
@SuppressWarnings("static-method")
1415
public class HashArrayMappedTreeTests {
1516

1617
@Test

src/com/jwetherell/algorithms/data_structures/test/HashMapTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1212
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1313

14+
@SuppressWarnings("static-method")
1415
public class HashMapTests {
1516

1617
@Test

src/com/jwetherell/algorithms/data_structures/test/IntervalTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.jwetherell.algorithms.data_structures.IntervalTree;
1212

13+
@SuppressWarnings("static-method")
1314
public class IntervalTreeTests {
1415

1516
private static boolean collectionsEqual(Collection<?> c1, Collection<?> c2) {

src/com/jwetherell/algorithms/data_structures/test/KdTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.jwetherell.algorithms.data_structures.KdTree;
1111

12+
@SuppressWarnings("static-method")
1213
public class KdTreeTests {
1314

1415
@Test

src/com/jwetherell/algorithms/data_structures/test/ListTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class ListTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/MatrixTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.jwetherell.algorithms.data_structures.Matrix;
88

9+
@SuppressWarnings("static-method")
910
public class MatrixTests {
1011

1112
@Test

src/com/jwetherell/algorithms/data_structures/test/PatriciaTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class PatriciaTreeTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/QuadTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.jwetherell.algorithms.data_structures.QuadTree;
1212

13+
@SuppressWarnings("static-method")
1314
public class QuadTreeTests {
1415

1516
private static final Random RANDOM = new Random();

src/com/jwetherell/algorithms/data_structures/test/QueueTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class QueueTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/RadixTrieTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1212
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1313

14+
@SuppressWarnings("static-method")
1415
public class RadixTrieTests {
1516

1617
@Test

src/com/jwetherell/algorithms/data_structures/test/RedBlackTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class RedBlackTreeTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/SegmentTreeTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
import com.jwetherell.algorithms.data_structures.SegmentTree.DynamicSegmentTree;
1313
import com.jwetherell.algorithms.data_structures.SegmentTree.FlatSegmentTree;
1414

15+
@SuppressWarnings("static-method")
1516
public class SegmentTreeTests {
1617

1718
private static boolean collectionsEqual(Collection<?> c1, Collection<?> c2) {
1819
if (c1.size()!=c2.size()) return false;
1920
return c1.containsAll(c2) && c2.containsAll(c1);
2021
}
2122

23+
@SuppressWarnings("cast")
2224
@Test
2325
public void testSegmentTree() {
2426
{ // Quadrant Segment tree

src/com/jwetherell/algorithms/data_structures/test/SkipListMapTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1212
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1313

14+
@SuppressWarnings("static-method")
1415
public class SkipListMapTests {
1516

1617
@Test

src/com/jwetherell/algorithms/data_structures/test/SkipListTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class SkipListTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/SplayTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1515
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1616

17+
@SuppressWarnings("static-method")
1718
public class SplayTreeTests {
1819

1920
@Test

src/com/jwetherell/algorithms/data_structures/test/StackTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class StackTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/SuffixTreeTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.jwetherell.algorithms.data_structures.SuffixTree;
88
import com.jwetherell.algorithms.data_structures.test.common.SuffixTreeTest;
99

10+
@SuppressWarnings("static-method")
1011
public class SuffixTreeTests {
1112

1213
@Test

src/com/jwetherell/algorithms/data_structures/test/SuffixTrieTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.jwetherell.algorithms.data_structures.SuffixTrie;
88
import com.jwetherell.algorithms.data_structures.test.common.SuffixTreeTest;
99

10+
@SuppressWarnings("static-method")
1011
public class SuffixTrieTests {
1112

1213
@Test

src/com/jwetherell/algorithms/data_structures/test/TreapTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1515
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1616

17+
@SuppressWarnings("static-method")
1718
public class TreapTests {
1819

1920
@Test

src/com/jwetherell/algorithms/data_structures/test/TreeMapTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1212
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1313

14+
@SuppressWarnings("static-method")
1415
public class TreeMapTests {
1516

1617
@Test

src/com/jwetherell/algorithms/data_structures/test/TrieMapTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1212
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1313

14+
@SuppressWarnings("static-method")
1415
public class TrieMapTests {
1516

1617
@Test

src/com/jwetherell/algorithms/data_structures/test/TrieTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jwetherell.algorithms.data_structures.test.common.Utils.TestData;
1414
import com.jwetherell.algorithms.data_structures.test.common.Utils.Type;
1515

16+
@SuppressWarnings("static-method")
1617
public class TrieTests {
1718

1819
@Test

src/com/jwetherell/algorithms/data_structures/test/common/Utils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class Utils {
77

8-
public static enum Type {Integer, String};
8+
public static enum Type {Integer, String}
99

1010
public static void handleError(Object obj) {
1111
System.err.println(obj.toString());

src/com/jwetherell/algorithms/data_structures/timing/DataStructuresTiming.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class DataStructuresTiming {
5555
private static int testIndex = 0; // Index into the tests
5656
private static int testNumber = 0; // Number of aggregate tests which have been run
5757

58-
private static enum Type {Integer, String};
58+
private static enum Type {Integer, String}
5959

6060
public static void main(String[] args) {
6161
System.out.println("Starting tests.");
@@ -1582,7 +1582,7 @@ private static <K,V> boolean testJavaMap(java.util.Map<K,V> map, Type keyType, S
15821582
return true;
15831583
}
15841584

1585-
private static final String getTestResults(int testNumber, String[] names, long[][] results) {
1585+
private static final String getTestResults(int number, String[] names, long[][] results) {
15861586
StringBuilder resultsBuilder = new StringBuilder();
15871587
String format = "%-32s %-10s %-15s %-15s %-20s %-15s %-15s\n";
15881588
Formatter formatter = new Formatter(resultsBuilder, Locale.US);
@@ -1600,7 +1600,7 @@ private static final String getTestResults(int testNumber, String[] names, long[
16001600
long[] result = results[i];
16011601
if (name != null && result != null) {
16021602
double addTime = result[0] / MILLIS;
1603-
addTime /= testNumber;
1603+
addTime /= number;
16041604
String addTimeString = null;
16051605
if (addTime > MINUTES) {
16061606
addTime /= MINUTES;
@@ -1613,7 +1613,7 @@ private static final String getTestResults(int testNumber, String[] names, long[
16131613
}
16141614

16151615
double removeTime = result[1] / MILLIS;
1616-
removeTime /= testNumber;
1616+
removeTime /= number;
16171617
String removeTimeString = null;
16181618
if (removeTime > MINUTES) {
16191619
removeTime /= MINUTES;
@@ -1627,7 +1627,7 @@ private static final String getTestResults(int testNumber, String[] names, long[
16271627

16281628
// sorted
16291629
double addSortedTime = result[2] / MILLIS;
1630-
addSortedTime /= testNumber;
1630+
addSortedTime /= number;
16311631
String sortedAddTimeString = null;
16321632
if (addSortedTime > MINUTES) {
16331633
addSortedTime /= MINUTES;
@@ -1640,7 +1640,7 @@ private static final String getTestResults(int testNumber, String[] names, long[
16401640
}
16411641

16421642
double removeSortedTime = result[3] / MILLIS;
1643-
removeSortedTime /= testNumber;
1643+
removeSortedTime /= number;
16441644
String sortedRemoveTimeString = null;
16451645
if (removeSortedTime > MINUTES) {
16461646
removeSortedTime /= MINUTES;
@@ -1653,7 +1653,7 @@ private static final String getTestResults(int testNumber, String[] names, long[
16531653
}
16541654

16551655
double lookupTime = result[4] / MILLIS;
1656-
lookupTime /= testNumber;
1656+
lookupTime /= number;
16571657
String lookupTimeString = null;
16581658
if (lookupTime > MINUTES) {
16591659
lookupTime /= MINUTES;
@@ -1666,7 +1666,7 @@ private static final String getTestResults(int testNumber, String[] names, long[
16661666
}
16671667

16681668
double size = result[5];
1669-
size /= testNumber;
1669+
size /= number;
16701670
String sizeString = null;
16711671
if (size > MB) {
16721672
size = size / MB;

src/com/jwetherell/algorithms/graph/test/Graphs.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.jwetherell.algorithms.graph.Prim;
2424
import com.jwetherell.algorithms.graph.TopologicalSort;
2525

26+
@SuppressWarnings("static-method")
2627
public class Graphs {
2728

2829
private static int debug = 0; // Debug level. 0=None, 1=Some
@@ -849,11 +850,11 @@ public void topologicalSortOnDirectedGraph() {
849850
Graph.Edge<Integer> ce4_5 = new Graph.Edge<Integer>(6, cv4, cv5);
850851
edges.add(ce4_5);
851852

852-
Graph<Integer> directed = new Graph<Integer>(Graph.TYPE.DIRECTED, verticies, edges);
853-
if (debug > 0) System.out.println(directed.toString());
853+
Graph<Integer> digraph = new Graph<Integer>(Graph.TYPE.DIRECTED, verticies, edges);
854+
if (debug > 0) System.out.println(digraph.toString());
854855

855856
System.out.println("Topological sort of the directed graph.");
856-
List<Graph.Vertex<Integer>> results = TopologicalSort.sort(directed);
857+
List<Graph.Vertex<Integer>> results = TopologicalSort.sort(digraph);
857858
if (debug > 0) System.out.println("result=" + results);
858859
assertTrue("Topological sort error. results="+results, results.size()!=0);
859860

src/com/jwetherell/algorithms/mathematics/test/Mathematics.java

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.jwetherell.algorithms.mathematics.Multiplication;
1616
import com.jwetherell.algorithms.mathematics.Primes;
1717

18+
@SuppressWarnings("static-method")
1819
public class Mathematics {
1920

2021
private static final int MIN = 1;

src/com/jwetherell/algorithms/numbers/test/Numbers.java

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.jwetherell.algorithms.numbers.Integers;
1111
import com.jwetherell.algorithms.numbers.Longs;
1212

13+
@SuppressWarnings("static-method")
1314
public class Numbers {
1415

1516
private static final Random RANDOM = new Random();

src/com/jwetherell/algorithms/search/test/Search.java

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.jwetherell.algorithms.search.LinearSearch;
1010
import com.jwetherell.algorithms.search.QuickSelect;
1111

12+
@SuppressWarnings("static-method")
1213
public class Search {
1314

1415
private static final int SIZE = 9999;

src/com/jwetherell/algorithms/sequence/test/Sequences.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jwetherell.algorithms.sequence.LongestCommonSubsequence;
1212
import com.jwetherell.algorithms.sequence.TotalOfSequence;
1313

14+
@SuppressWarnings("static-method")
1415
public class Sequences {
1516

1617
@Test

src/com/jwetherell/algorithms/sorts/test/Sorts.java

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.jwetherell.algorithms.sorts.RadixSort;
1717
import com.jwetherell.algorithms.sorts.ShellSort;
1818

19+
@SuppressWarnings("static-method")
1920
public class Sorts {
2021

2122
private static final Random RANDOM = new Random();

src/com/jwetherell/algorithms/strings/test/Strings.java

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.jwetherell.algorithms.strings.StringFunctions;
1111

12+
@SuppressWarnings("static-method")
1213
public class Strings {
1314

1415
@Test

0 commit comments

Comments
 (0)