mirror of
https://bitbucket.org/Mattrixwv/javaclasses.git
synced 2025-12-07 07:23:57 -05:00
Updated more sonarqube findings
This commit is contained in:
@@ -38,13 +38,13 @@ public class TestNumberAlgorithms{
|
||||
public void testGetPrimes(){
|
||||
//Test 1
|
||||
List<Integer> correctAnswer = Arrays.asList(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97);
|
||||
Integer topNum = 100;
|
||||
int topNum = 100;
|
||||
List<Integer> answer = NumberAlgorithms.getPrimes(topNum);
|
||||
assertEquals("getPrimes Integer failed", correctAnswer, answer);
|
||||
|
||||
//Test 2
|
||||
List<Long> longCorrectAnswer = Arrays.asList(2L, 3L, 5L, 7L, 11L, 13L, 17L, 19L, 23L, 29L, 31L, 37L, 41L, 43L, 47L, 53L, 59L, 61L, 67L, 71L, 73L, 79L, 83L, 89L, 97L);
|
||||
Long longTopNum = 100L;
|
||||
long longTopNum = 100L;
|
||||
List<Long> longAnswer = NumberAlgorithms.getPrimes(longTopNum);
|
||||
assertEquals("getPrimes Long failed", longCorrectAnswer, longAnswer);
|
||||
|
||||
@@ -59,13 +59,13 @@ public class TestNumberAlgorithms{
|
||||
public void testGetNumPrimes(){
|
||||
//Test 1
|
||||
List<Integer> correctAnswer = Arrays.asList(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97);
|
||||
Integer numPrimes = 25;
|
||||
int numPrimes = 25;
|
||||
List<Integer> answer = NumberAlgorithms.getNumPrimes(numPrimes);
|
||||
assertEquals("getNumPrimes Integer failed", correctAnswer, answer);
|
||||
|
||||
//Test 2
|
||||
List<Long> longCorrectAnswer = Arrays.asList(2L, 3L, 5L, 7L, 11L, 13L, 17L, 19L, 23L, 29L, 31L, 37L, 41L, 43L, 47L, 53L, 59L, 61L, 67L, 71L, 73L, 79L, 83L, 89L, 97L);
|
||||
Long longNumPrimes = 25L;
|
||||
long longNumPrimes = 25L;
|
||||
List<Long> longAnswer = NumberAlgorithms.getNumPrimes(longNumPrimes);
|
||||
assertEquals("getNumPrimes Long failed", longCorrectAnswer, longAnswer);
|
||||
|
||||
@@ -146,7 +146,7 @@ public class TestNumberAlgorithms{
|
||||
public void testGetFactors() throws InvalidResult{
|
||||
//Test 1
|
||||
List<Integer> correctAnswer = Arrays.asList(2, 2, 5, 5);
|
||||
Integer number = 100;
|
||||
int number = 100;
|
||||
List<Integer> answer = NumberAlgorithms.getFactors(number);
|
||||
assertEquals("getFactors Integer 1 failed", correctAnswer, answer);
|
||||
//Test 2
|
||||
@@ -157,7 +157,7 @@ public class TestNumberAlgorithms{
|
||||
|
||||
//Test 3
|
||||
List<Long> longCorrectAnswer = Arrays.asList(2L, 2L, 5L, 5L);
|
||||
Long longNumber = 100L;
|
||||
long longNumber = 100L;
|
||||
List<Long> longAnswer = NumberAlgorithms.getFactors(longNumber);
|
||||
assertEquals("getFactors Long failed", longCorrectAnswer, longAnswer);
|
||||
|
||||
@@ -172,7 +172,7 @@ public class TestNumberAlgorithms{
|
||||
public void testGetDivisors(){
|
||||
//Test 1
|
||||
List<Integer> correctAnswer = Arrays.asList(1, 2, 4, 5, 10, 20, 25, 50, 100);
|
||||
Integer topNum = 100;
|
||||
int topNum = 100;
|
||||
List<Integer> answer = NumberAlgorithms.getDivisors(topNum);
|
||||
assertEquals("getDivisors Integer 1 failed", correctAnswer, answer);
|
||||
//Test 2
|
||||
@@ -207,9 +207,9 @@ public class TestNumberAlgorithms{
|
||||
@Test
|
||||
public void testGetFib(){
|
||||
//Test 1
|
||||
Integer correctAnswer = 144;
|
||||
Integer number = 12;
|
||||
Integer answer = NumberAlgorithms.getFib(number);
|
||||
int correctAnswer = 144;
|
||||
int number = 12;
|
||||
int answer = NumberAlgorithms.getFib(number);
|
||||
assertEquals("getFib Integer 1 failed", correctAnswer, answer);
|
||||
//Test 2
|
||||
correctAnswer = 6765;
|
||||
@@ -218,9 +218,9 @@ public class TestNumberAlgorithms{
|
||||
assertEquals("getFib Integer 2 failed", correctAnswer, answer);
|
||||
|
||||
//Test 3
|
||||
Long longCorrectAnswer = 6765L;
|
||||
Long longNumber = 20L;
|
||||
Long longAnswer = NumberAlgorithms.getFib(longNumber);
|
||||
long longCorrectAnswer = 6765L;
|
||||
long longNumber = 20L;
|
||||
long longAnswer = NumberAlgorithms.getFib(longNumber);
|
||||
assertEquals("getFib Long failed", longCorrectAnswer, longAnswer);
|
||||
|
||||
//Test 4
|
||||
@@ -234,7 +234,7 @@ public class TestNumberAlgorithms{
|
||||
public void testGetAllFib(){
|
||||
//Test 1
|
||||
List<Integer> correctAnswer = Arrays.asList(1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89);
|
||||
Integer highestNumber = 100;
|
||||
int highestNumber = 100;
|
||||
List<Integer> answer = NumberAlgorithms.getAllFib(highestNumber);
|
||||
assertEquals("getAllFib Integer 1 failed", correctAnswer, answer);
|
||||
//Test 2
|
||||
@@ -245,7 +245,7 @@ public class TestNumberAlgorithms{
|
||||
|
||||
//Test 3
|
||||
List<Long> longCorrectAnswer = Arrays.asList(1L, 1L, 2L, 3L, 5L, 8L, 13L, 21L, 34L, 55L, 89L, 144L, 233L, 377L, 610L, 987L);
|
||||
Long longHighestNumber = 1000L;
|
||||
long longHighestNumber = 1000L;
|
||||
List<Long> longAnswer = NumberAlgorithms.getAllFib(longHighestNumber);
|
||||
assertEquals("getAllFib Long failed", longCorrectAnswer, longAnswer);
|
||||
|
||||
@@ -260,9 +260,9 @@ public class TestNumberAlgorithms{
|
||||
public void testFactorial(){
|
||||
//Integer
|
||||
//Test 1
|
||||
Integer correctAnswer = 720;
|
||||
Integer number = 6;
|
||||
Integer answer = NumberAlgorithms.factorial(number);
|
||||
int correctAnswer = 720;
|
||||
int number = 6;
|
||||
int answer = NumberAlgorithms.factorial(number);
|
||||
assertEquals("factorial Integer 1 failed", correctAnswer, answer);
|
||||
//Test 2
|
||||
correctAnswer = 479001600;
|
||||
@@ -272,9 +272,9 @@ public class TestNumberAlgorithms{
|
||||
|
||||
//Long
|
||||
//Test 3
|
||||
Long correctAnswerLong = 720L;
|
||||
Long numberLong = 6L;
|
||||
Long answerLong = NumberAlgorithms.factorial(numberLong);
|
||||
long correctAnswerLong = 720L;
|
||||
long numberLong = 6L;
|
||||
long answerLong = NumberAlgorithms.factorial(numberLong);
|
||||
assertEquals("factorial Long 1 failed", correctAnswerLong, answerLong);
|
||||
//Test 4
|
||||
correctAnswerLong = 479001600L;
|
||||
@@ -309,6 +309,7 @@ public class TestNumberAlgorithms{
|
||||
answerBig = NumberAlgorithms.factorial(numberBig);
|
||||
assertEquals("factorial BigInteger 4 failed", correctAnswerBig, answerBig);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGCD(){
|
||||
//Test 1
|
||||
@@ -368,6 +369,7 @@ public class TestNumberAlgorithms{
|
||||
bigAnswer = NumberAlgorithms.gcd(bigNum1, bigNum2);
|
||||
assertEquals("GCD BigInteger 3 failed", bigCorrectAnswer, bigAnswer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToBin(){
|
||||
//Test 1
|
||||
|
||||
Reference in New Issue
Block a user