Started verification tests

This commit is contained in:
2022-12-04 23:27:25 -05:00
parent 62a8589364
commit 7a3f2214f8
20 changed files with 721 additions and 7 deletions

View File

@@ -0,0 +1,62 @@
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 TestProblem6 extends BaseTest{
@InjectMocks
private Problem6 problem;
@Test
@Override
public void testDescription(){
assertEquals("Find the difference between the sum of the squares and the square of the sum of the numbers 1-100.", problem.getDescription());
assertFalse(problem.getSolved());
}
@Test
@Override
public void testSolve(){
assertThrows(Unsolved.class, () -> { problem.getSumOfSquares(); });
assertThrows(Unsolved.class, () -> { problem.getSquareOfSum(); });
assertThrows(Unsolved.class, () -> { problem.getDifference(); });
problem.solve();
//Verify result
assertEquals(338350, problem.getSumOfSquares());
assertEquals(25502500, problem.getSquareOfSum());
assertEquals(25164150, problem.getDifference());
assertEquals("The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is 25164150", problem.getResult());
//Verify the problem variables and functions were called
verifyProblem(problem);
//Verify the problem 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();
}
}