Commit 0739ce29 authored by WinJ's avatar WinJ
Browse files

refactored tests

parent 5a33f2a1
......@@ -52,10 +52,4 @@ public class CountStrs {
return 0; // TODO: you may want to change this
}
}
public static void main(String[] args) {
String[] arr = {"h", "ee", "llll", "llll", "oo", "llll"};
System.out.println(parallel(arr, "llll") + " should be 3.");
System.out.println(parallel(arr, "h") + " should be 1.");
}
}
......@@ -46,8 +46,4 @@ public class LessThan7 {
}
}
public static void main(String[] args) {
System.out.println(parallel(new int[]{21, 7, 6, 8, 17, 1, 7, 7, 1, 1, 7}) + " should be 4.");
}
}
......@@ -50,9 +50,4 @@ public class Parity {
return false; // TODO: you may want to change this
}
}
public static void main(String[] args) {
System.out.println(parallel(new int[]{1, 7, 4, 3, 6}) + " should be true.");
System.out.println(parallel(new int[]{6, 5, 4, 3, 2, 1}) + " should be false.");
}
}
......@@ -52,10 +52,4 @@ public class PowMod {
}
}
public static void main(String[] args) {
int[] arr = {1, 7, 4, 3, 6};
parallel(arr, 6, 5000);
System.out.println(Arrays.toString(arr) + " should be [1, 2649, 4096, 729, 1656]");
}
}
......@@ -69,9 +69,4 @@ public class SecondSmallest {
return new TwoSmallest(); // TODO: you may want to change this
}
}
public static void main(String[] args) {
System.out.println(parallel(new int[]{1, 7, 4, 3, 6}) + " should be 3.");
System.out.println(parallel(new int[]{6, 1, 4, 3, 5, 2, 1}) + " should be 2.");
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class CountStrsTests {
@Test
public void testCountStrs() {
String[] arr = {"h", "ee", "llll", "llll", "oo", "llll"};
assertEquals(3, CountStrs.parallel(arr, "llll"));
assertEquals(1, CountStrs.parallel(arr, "h"));
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class LessThan7Tests {
@Test
public void testLessThan7() {
assertEquals(4, LessThan7.parallel(new int[]{21, 7, 6, 8, 17, 1, 7, 7, 1, 1, 7}));
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class ParityTests {
@Test
public void testParity() {
assertTrue(Parity.parallel(new int[]{1, 7, 4, 3, 6}));
assertFalse(Parity.parallel(new int[]{6, 5, 4, 3, 2, 1}));
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class PowModTests {
@Test
public void testPowMod() {
int[] arr = {1, 7, 4, 3, 6};
int[] expected = {1, 2649, 4096, 729, 1656};
PowMod.parallel(arr, 6, 5000);
assertArrayEquals(expected, arr);
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class SecondSmallestTests {
@Test
public void testSecondSmallest() {
assertEquals(3, SecondSmallest.parallel(new int[]{1, 7, 4, 3, 6}));
assertEquals(2, SecondSmallest.parallel(new int[]{6, 1, 4, 3, 5, 2, 1}));
}
}
import org.junit.Test;
import static org.junit.Assert.*;
public class TestBasic {
@Test
public void testCountStrs() {
String[] arr = {"h", "ee", "llll", "llll", "oo", "llll"};
assertEquals(3, CountStrs.parallel(arr, "llll"));
assertEquals(1, CountStrs.parallel(arr, "h"));
}
@Test
public void testLessThan7() {
assertEquals(4, LessThan7.parallel(new int[]{21, 7, 6, 8, 17, 1, 7, 7, 1, 1, 7}));
}
@Test
public void testParity() {
assertTrue(Parity.parallel(new int[]{1, 7, 4, 3, 6}));
assertFalse(Parity.parallel(new int[]{6, 5, 4, 3, 2, 1}));
}
@Test
public void testPowMod() {
int[] arr = {1, 7, 4, 3, 6};
int[] expected = {1, 2649, 4096, 729, 1656};
PowMod.parallel(arr, 6, 5000);
assertArrayEquals(expected, arr);
}
@Test
public void testSecondSmallest() {
assertEquals(3, SecondSmallest.parallel(new int[]{1, 7, 4, 3, 6}));
assertEquals(2, SecondSmallest.parallel(new int[]{6, 1, 4, 3, 5, 2, 1}));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment