diff --git a/src/main/java/mattrixwv/Stopwatch.java b/src/main/java/mattrixwv/Stopwatch.java index 7a3f835..6b84463 100644 --- a/src/main/java/mattrixwv/Stopwatch.java +++ b/src/main/java/mattrixwv/Stopwatch.java @@ -1,10 +1,10 @@ //JavaClasses/src/main/java/mattrixwv/Stopwatch.java //Matthew Ellison (Mattrixwv) // Created: 03-01-19 -//Modified: 07-28-20 +//Modified: 06-26-22 //This file contains a class that is used to time the execution time of other programs /* -Copyright (C) 2020 Matthew Ellison +Copyright (C) 2022 Matthew Ellison This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -71,27 +71,27 @@ public class Stopwatch{ stopTime = null; } //Returns the time in nanoseconds - public double getNano() throws InvalidResult{ + public double getNano(){ return getTime().doubleValue(); } //Returns the time in microseconds - public double getMicro() throws InvalidResult{ + public double getMicro(){ return getTime().doubleValue() / 1000D; } //Returns the time in milliseconds - public double getMilli() throws InvalidResult{ + public double getMilli(){ return getTime().doubleValue() / 1000000D; } //Returns the time in seconds - public double getSecond() throws InvalidResult{ + public double getSecond(){ return getTime().doubleValue() / 1000000000D; } //Returns the time in minutes - public double getMinute() throws InvalidResult{ + public double getMinute(){ return getTime().doubleValue() / 60000000000D; } //Returns the time in hours - public double getHour() throws InvalidResult{ + public double getHour(){ return getTime().doubleValue() / 3600000000000D; } //Returns the time as a string at the 'best' resolution. (Goal is xxx.xxx) diff --git a/src/test/java/mattrixwv/TestNumberAlgorithms.java b/src/test/java/mattrixwv/TestNumberAlgorithms.java index f6a2dec..801980f 100644 --- a/src/test/java/mattrixwv/TestNumberAlgorithms.java +++ b/src/test/java/mattrixwv/TestNumberAlgorithms.java @@ -170,8 +170,6 @@ public class TestNumberAlgorithms{ @Test public void testGetDivisors(){ - Stopwatch timer = new Stopwatch(); - timer.start(); //Test 1 List correctAnswer = Arrays.asList(1, 2, 4, 5, 10, 20, 25, 50, 100); Integer topNum = 100; @@ -204,8 +202,6 @@ public class TestNumberAlgorithms{ bigTopNum = BigInteger.valueOf(6); bigAnswer = NumberAlgorithms.getDivisors(bigTopNum); assertEquals("getDivisors BigInteger 2 failed", bigCorrectAnswer, bigAnswer); - timer.stop(); - System.out.println("timer = " + timer.toString()); } @Test diff --git a/src/test/java/mattrixwv/TestStopwatch.java b/src/test/java/mattrixwv/TestStopwatch.java index 7c67cf8..c2f2b17 100644 --- a/src/test/java/mattrixwv/TestStopwatch.java +++ b/src/test/java/mattrixwv/TestStopwatch.java @@ -26,6 +26,7 @@ package mattrixwv; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; import org.junit.Test; @@ -39,6 +40,7 @@ public class TestStopwatch{ Stopwatch timer = new Stopwatch(); timer.start(); timer.stop(); + assertNotNull(timer.toString()); //If it gets to here without throwing an exception everything went well } @Test