Updated long running problem to test smaller dataset

This commit is contained in:
2022-12-06 18:41:20 -05:00
parent 5bdb9f8110
commit d48d245110
6 changed files with 50 additions and 37 deletions

View File

@@ -4,7 +4,6 @@ package com.mattrixwv.project_euler.problems;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -17,29 +16,28 @@ import com.mattrixwv.project_euler.exceptions.Unsolved;
@ExtendWith(MockitoExtension.class)
public class TestProblem24 extends BaseTest{
@InjectMocks
private Problem24 problem;
private Problem24Override problem;
@Test
@Override
public void testDescription(){
assertEquals("What is the millionth lexicographic permutation of the digits 0123456789?", problem.getDescription());
assertEquals("What is the 100th lexicographic permutation of the digits 01234?", problem.getDescription());
assertFalse(problem.getSolved());
}
@Test
@Override
public void testSolve(){
assumeTrue(Boolean.valueOf(System.getProperty("longTests")));
assertThrows(Unsolved.class, () -> { problem.getPermutationsList(); });
assertThrows(Unsolved.class, () -> { problem.getPermutation(); });
problem.solve();
//Verify result
assertEquals(3628800, problem.getPermutationsList().size());
assertEquals("2783915460", problem.getPermutation());
assertEquals("The 1 millionth permutation is 2783915460", problem.getResult());
assertEquals(120, problem.getPermutationsList().size());
assertEquals("40231", problem.getPermutation());
assertEquals("The 100th permutation is 40231", problem.getResult());
//Verify the problem variables and functions were called
verifyProblem(problem);
@@ -50,7 +48,6 @@ public class TestProblem24 extends BaseTest{
@Test
@Override
public void testReset(){
assumeTrue(Boolean.valueOf(System.getProperty("longTests")));
problem.reset();
//Verify solved was reset
@@ -60,4 +57,12 @@ public class TestProblem24 extends BaseTest{
//Verify the problem can be solved again
testSolve();
}
public static class Problem24Override extends Problem24{
static{
neededPerm = 100;
nums = "01234";
}
}
}