mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Started verification tests
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
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.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 TestProblem8 extends BaseTest{
|
||||
@InjectMocks
|
||||
private Problem8 problem;
|
||||
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription(){
|
||||
assertEquals("Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?", problem.getDescription());
|
||||
assertFalse(problem.getSolved());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSolve(){
|
||||
assertThrows(Unsolved.class, () -> { problem.getLargestNums(); });
|
||||
assertThrows(Unsolved.class, () -> { problem.getLargestProduct(); });
|
||||
|
||||
problem.solve();
|
||||
|
||||
//Verify result
|
||||
assertEquals("5576689664895", problem.getLargestNums());
|
||||
assertEquals(23514624000L, problem.getLargestProduct());
|
||||
assertEquals(String.format("The greatest product is 23514624000%nThe numbers are 5576689664895"), problem.getResult());
|
||||
//Verify the problem variables and functions were called
|
||||
verifyProblem(problem);
|
||||
|
||||
//Verify the porblem won't be run again
|
||||
verifyProblemSecondRun(problem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testReset(){
|
||||
problem.reset();
|
||||
|
||||
//Verify solved was reset
|
||||
assertFalse(problem.getSolved());
|
||||
super.testReset();
|
||||
|
||||
//Verify the problem can be solved again
|
||||
testSolve();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user