From cb99becf3dc8c8329e544fc12ca617a76710cb32 Mon Sep 17 00:00:00 2001 From: Giorgos Stamatelatos Date: Mon, 2 Jul 2018 12:38:12 +0300 Subject: [PATCH] Define STREAM parameter locally on tests --- .../java/gr/james/sampling/RandomSamplingTest.java | 13 ++++++++----- .../james/sampling/WeightedRandomSamplingTest.java | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/test/java/gr/james/sampling/RandomSamplingTest.java b/src/test/java/gr/james/sampling/RandomSamplingTest.java index 3afd4bb..73cc19c 100644 --- a/src/test/java/gr/james/sampling/RandomSamplingTest.java +++ b/src/test/java/gr/james/sampling/RandomSamplingTest.java @@ -17,7 +17,6 @@ public class RandomSamplingTest { private static final Random RANDOM = new Random(); - private static final int STREAM = 20; private static final int SAMPLE = 10; private static final int REPS = 1000000; @@ -40,10 +39,12 @@ public static Collection>> implementations() { } /** - * All items must be selected with equal probability. + * All items must be selected with equal probability. Using 20 stream elements. */ @Test - public void correctness() { + public void correctness20() { + final int STREAM = 20; + final int[] d = new int[STREAM]; for (int reps = 0; reps < REPS; reps++) { @@ -66,10 +67,12 @@ public void correctness() { } /** - * Same test as {@link #correctness()} but with the stream API. + * Same test as {@link #correctness20()} but with the stream API. Using 20 stream elements. */ @Test - public void stream() { + public void stream20() { + final int STREAM = 20; + final int[] d = new int[STREAM]; for (int reps = 0; reps < REPS; reps++) { diff --git a/src/test/java/gr/james/sampling/WeightedRandomSamplingTest.java b/src/test/java/gr/james/sampling/WeightedRandomSamplingTest.java index 8ef3d52..96f968d 100644 --- a/src/test/java/gr/james/sampling/WeightedRandomSamplingTest.java +++ b/src/test/java/gr/james/sampling/WeightedRandomSamplingTest.java @@ -18,7 +18,6 @@ public class WeightedRandomSamplingTest { private static final Random RANDOM = new Random(); - private static final int STREAM = 20; private static final int SAMPLE = 10; private static final int REPS = 1000000; @@ -37,10 +36,12 @@ public static Collection>> implementati } /** - * Increased weight means more occurrences. + * Increased weight means more occurrences. Using 20 stream elements. */ @Test - public void correctness() { + public void correctness20() { + final int STREAM = 20; + final int[] d = new int[STREAM]; for (int reps = 0; reps < REPS; reps++) { @@ -61,10 +62,12 @@ public void correctness() { } /** - * Same test as {@link #correctness()} but with the stream API. + * Same test as {@link #correctness20()} but with the stream API. Using 20 stream elements. */ @Test - public void stream() { + public void stream20() { + final int STREAM = 20; + final int[] d = new int[STREAM]; for (int reps = 0; reps < REPS; reps++) {