mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Update test coverage
This commit is contained in:
@@ -4,31 +4,33 @@ package com.mattrixwv.project_euler.problems;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
import com.mattrixwv.project_euler.exceptions.Unsolved;
|
||||
|
||||
|
||||
public class TestProblem36 extends ProblemBaseTest{
|
||||
public class TestProblem36 extends TestProblemBase{
|
||||
@InjectMocks
|
||||
private Problem36 problem;
|
||||
static{
|
||||
description = "Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.";
|
||||
result = "The sum of all base 10 and base 2 palindromic numbers < 999999 is 872187";
|
||||
}
|
||||
private List<Integer> palindromes = List.of(1, 3, 5, 7, 9, 33, 99, 313, 585, 717, 7447, 9009, 15351, 32223, 39993, 53235, 53835, 73737, 585585);
|
||||
private int sum = 872187;
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@Override
|
||||
public void testDescription(){
|
||||
super.testDescription(problem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@Override
|
||||
public void testSolve(){
|
||||
assertThrows(Unsolved.class, () -> { problem.getPalindromes(); });
|
||||
@@ -37,14 +39,23 @@ public class TestProblem36 extends ProblemBaseTest{
|
||||
super.testSolve(problem);
|
||||
|
||||
//Verify result
|
||||
assertEquals(19, problem.getPalindromes().size());
|
||||
assertEquals(872187, problem.getSumOfPalindromes());
|
||||
assertEquals(palindromes, problem.getPalindromes());
|
||||
assertEquals(sum, problem.getSumOfPalindromes());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@Override
|
||||
public void testReset(){
|
||||
problem.palindromes = new ArrayList<>(palindromes);
|
||||
problem.sum = sum;
|
||||
problem.solved = true;
|
||||
|
||||
super.testReset(problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyReset(){
|
||||
assertEquals(new ArrayList<>(), problem.palindromes);
|
||||
assertEquals(0, problem.sum);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user