Updated more sonarqube findings
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
//JavaClasses/src/main/java/mattrixwv/Stopwatch.java
|
//JavaClasses/src/main/java/mattrixwv/Stopwatch.java
|
||||||
//Matthew Ellison (Mattrixwv)
|
//Matthew Ellison (Mattrixwv)
|
||||||
// Created: 03-01-19
|
// 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
|
//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
|
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
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
@@ -71,27 +71,27 @@ public class Stopwatch{
|
|||||||
stopTime = null;
|
stopTime = null;
|
||||||
}
|
}
|
||||||
//Returns the time in nanoseconds
|
//Returns the time in nanoseconds
|
||||||
public double getNano() throws InvalidResult{
|
public double getNano(){
|
||||||
return getTime().doubleValue();
|
return getTime().doubleValue();
|
||||||
}
|
}
|
||||||
//Returns the time in microseconds
|
//Returns the time in microseconds
|
||||||
public double getMicro() throws InvalidResult{
|
public double getMicro(){
|
||||||
return getTime().doubleValue() / 1000D;
|
return getTime().doubleValue() / 1000D;
|
||||||
}
|
}
|
||||||
//Returns the time in milliseconds
|
//Returns the time in milliseconds
|
||||||
public double getMilli() throws InvalidResult{
|
public double getMilli(){
|
||||||
return getTime().doubleValue() / 1000000D;
|
return getTime().doubleValue() / 1000000D;
|
||||||
}
|
}
|
||||||
//Returns the time in seconds
|
//Returns the time in seconds
|
||||||
public double getSecond() throws InvalidResult{
|
public double getSecond(){
|
||||||
return getTime().doubleValue() / 1000000000D;
|
return getTime().doubleValue() / 1000000000D;
|
||||||
}
|
}
|
||||||
//Returns the time in minutes
|
//Returns the time in minutes
|
||||||
public double getMinute() throws InvalidResult{
|
public double getMinute(){
|
||||||
return getTime().doubleValue() / 60000000000D;
|
return getTime().doubleValue() / 60000000000D;
|
||||||
}
|
}
|
||||||
//Returns the time in hours
|
//Returns the time in hours
|
||||||
public double getHour() throws InvalidResult{
|
public double getHour(){
|
||||||
return getTime().doubleValue() / 3600000000000D;
|
return getTime().doubleValue() / 3600000000000D;
|
||||||
}
|
}
|
||||||
//Returns the time as a string at the 'best' resolution. (Goal is xxx.xxx)
|
//Returns the time as a string at the 'best' resolution. (Goal is xxx.xxx)
|
||||||
|
|||||||
@@ -170,8 +170,6 @@ public class TestNumberAlgorithms{
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDivisors(){
|
public void testGetDivisors(){
|
||||||
Stopwatch timer = new Stopwatch();
|
|
||||||
timer.start();
|
|
||||||
//Test 1
|
//Test 1
|
||||||
List<Integer> correctAnswer = Arrays.asList(1, 2, 4, 5, 10, 20, 25, 50, 100);
|
List<Integer> correctAnswer = Arrays.asList(1, 2, 4, 5, 10, 20, 25, 50, 100);
|
||||||
Integer topNum = 100;
|
Integer topNum = 100;
|
||||||
@@ -204,8 +202,6 @@ public class TestNumberAlgorithms{
|
|||||||
bigTopNum = BigInteger.valueOf(6);
|
bigTopNum = BigInteger.valueOf(6);
|
||||||
bigAnswer = NumberAlgorithms.getDivisors(bigTopNum);
|
bigAnswer = NumberAlgorithms.getDivisors(bigTopNum);
|
||||||
assertEquals("getDivisors BigInteger 2 failed", bigCorrectAnswer, bigAnswer);
|
assertEquals("getDivisors BigInteger 2 failed", bigCorrectAnswer, bigAnswer);
|
||||||
timer.stop();
|
|
||||||
System.out.println("timer = " + timer.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ package mattrixwv;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ public class TestStopwatch{
|
|||||||
Stopwatch timer = new Stopwatch();
|
Stopwatch timer = new Stopwatch();
|
||||||
timer.start();
|
timer.start();
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
assertNotNull(timer.toString());
|
||||||
//If it gets to here without throwing an exception everything went well
|
//If it gets to here without throwing an exception everything went well
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user