Files
ProjectEulerJava/src/test/java/com/mattrixwv/project_euler/problems/TestProblem20.java
2022-12-07 00:20:15 -05:00

55 lines
1.7 KiB
Java

package com.mattrixwv.project_euler.problems;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.math.BigInteger;
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 TestProblem20 extends ProblemBaseTest{
@InjectMocks
private Problem20 problem;
static{
description = "What is the sum of the digits of 100!?";
result = String.format("100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000%nThe sum of the digits is: 648");
}
@Test
@Order(1)
@Override
public void testDescription(){
super.testDescription(problem);
}
@Test
@Order(2)
@Override
public void testSolve(){
assertThrows(Unsolved.class, () -> { problem.getNumber(); });
assertThrows(Unsolved.class, () -> { problem.getNumberString(); });
assertThrows(Unsolved.class, () -> { problem.getSum(); });
super.testSolve(problem);
//Verify result
assertEquals(new BigInteger("93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000"), problem.getNumber());
assertEquals("93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000", problem.getNumberString());
assertEquals(648, problem.getSum());
}
@Test
@Order(3)
@Override
public void testReset(){
super.testReset(problem);
}
}