mirror of
https://bitbucket.org/Mattrixwv/javaclasses.git
synced 2025-12-06 23:13:57 -05:00
Added some exception handling
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user