Added some exception handling

This commit is contained in:
2020-08-24 14:50:04 -04:00
parent 019ed3244b
commit bf97b78219
5 changed files with 59 additions and 22 deletions

View File

@@ -32,6 +32,8 @@ import java.util.Arrays;
import org.junit.Test;
import mattrixwv.exceptions.InvalidResult;
public class TestAlgorithms{
@Test
@@ -75,7 +77,7 @@ public class TestAlgorithms{
assertEquals("getNumPrimes BigInteger failed", bigCorrectAnswer, bigAnswer);
}
@Test
public void testGetFactors(){
public void testGetFactors() throws InvalidResult{
//Test 1
ArrayList<Integer> correctAnswer = new ArrayList<Integer>(Arrays.asList(2, 2, 5, 5));
Integer number = 100;

View File

@@ -29,6 +29,8 @@ import static org.junit.Assert.assertNotEquals;
import org.junit.Test;
import mattrixwv.exceptions.InvalidResult;
public class TestStopwatch{
private static final Integer NUM_TO_RUN = 100000;
private static final Double ALLOWANCE = .0000000001;
@@ -40,7 +42,7 @@ public class TestStopwatch{
//If it gets to here without throwing an exception everything went well
}
@Test
public void testConversion(){
public void testConversion() throws InvalidResult{
Stopwatch timer = new Stopwatch();
Integer sum = 0;
//Start the timer
@@ -62,7 +64,7 @@ public class TestStopwatch{
assertEquals("Hour resolution test failed", timer.getHour(), (nano / 3600000000000D), ALLOWANCE);
}
@Test
public void testStringConversion(){
public void testStringConversion() throws InvalidResult{
//Test nanoseconds
String results = Stopwatch.getStr(1.0);
assertEquals("1.000 nanoseconds", results);