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,31 @@ 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 org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
import com.mattrixwv.project_euler.exceptions.Unsolved;
|
||||
|
||||
|
||||
public class TestProblem27 extends ProblemBaseTest{
|
||||
public class TestProblem27 extends TestProblemBase{
|
||||
@InjectMocks
|
||||
private Problem27 problem;
|
||||
static{
|
||||
description = "Find the product of the coefficients, |a| <= 999 and |b| <= 1000, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n=0";
|
||||
result = String.format("The greatest number of primes found is 70%nIt was found with A = -61, B = 971%nThe product of A and B is -59231");
|
||||
}
|
||||
private int topA = -61;
|
||||
private int topB = 971;
|
||||
private int topN = 70;
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@Override
|
||||
public void testDescription(){
|
||||
super.testDescription(problem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@Override
|
||||
public void testSolve(){
|
||||
assertThrows(Unsolved.class, () -> { problem.getTopA(); });
|
||||
@@ -39,16 +39,28 @@ public class TestProblem27 extends ProblemBaseTest{
|
||||
super.testSolve(problem);
|
||||
|
||||
//Verify result
|
||||
assertEquals(-61, problem.getTopA());
|
||||
assertEquals(971, problem.getTopB());
|
||||
assertEquals(70, problem.getTopN());
|
||||
assertEquals(-59231, problem.getProduct());
|
||||
assertEquals(topA, problem.getTopA());
|
||||
assertEquals(topB, problem.getTopB());
|
||||
assertEquals(topN, problem.getTopN());
|
||||
assertEquals(topA * topB, problem.getProduct());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@Override
|
||||
public void testReset(){
|
||||
//Setup
|
||||
problem.topA = topA;
|
||||
problem.topB = topB;
|
||||
problem.topN = topN;
|
||||
problem.solved = true;
|
||||
|
||||
super.testReset(problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyReset(){
|
||||
assertEquals(0, problem.topA);
|
||||
assertEquals(0, problem.topB);
|
||||
assertEquals(0, problem.topN);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user