mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Changed test methods
This commit is contained in:
@@ -2,60 +2,50 @@ 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 org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import com.mattrixwv.project_euler.exceptions.Unsolved;
|
||||
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class TestProblem24 extends BaseTest{
|
||||
@InjectMocks
|
||||
private Problem24Override problem;
|
||||
static{
|
||||
description = "What is the 100th lexicographic permutation of the digits 01234?";
|
||||
result = "The 100th permutation is 40231";
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@Override
|
||||
public void testDescription(){
|
||||
assertEquals("What is the 100th lexicographic permutation of the digits 01234?", problem.getDescription());
|
||||
assertFalse(problem.getSolved());
|
||||
super.testDescription(problem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
@Override
|
||||
public void testSolve(){
|
||||
assertThrows(Unsolved.class, () -> { problem.getPermutationsList(); });
|
||||
assertThrows(Unsolved.class, () -> { problem.getPermutation(); });
|
||||
|
||||
problem.solve();
|
||||
super.testSolve(problem);
|
||||
|
||||
//Verify result
|
||||
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);
|
||||
|
||||
//Verify the problem won't be run again
|
||||
verifyProblemSecondRun(problem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@Override
|
||||
public void testReset(){
|
||||
problem.reset();
|
||||
|
||||
//Verify solved was reset
|
||||
assertFalse(problem.getSolved());
|
||||
super.testReset();
|
||||
|
||||
//Verify the problem can be solved again
|
||||
testSolve();
|
||||
super.testReset(problem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user