| 1234567891011121314151617181920212223242526272829303132333435 |
- import org.example.PrimeFactorsCalculator;
- import org.junit.jupiter.api.Test;
- import java.util.List;
- import static java.util.Collections.EMPTY_LIST;
- import static org.junit.jupiter.api.Assertions.assertIterableEquals;
- public class PrimeFactorsCalculatorTest {
- private PrimeFactorsCalculator calculator = new PrimeFactorsCalculator();
- @Test
- void testGetFactorsValue1(){
- List<Integer> factors = calculator.getFactors(1);
- test(EMPTY_LIST,1);
- }
- @Test
- void testGetFactorsValues2() {
- test(List.of(2, 2), 4);
- test(List.of(2), 2);
- test(List.of(3), 3);
- test(List.of(2, 2), 4);
- test(List.of(5), 5);
- test(List.of(2, 3), 6);
- test(List.of(7), 7);
- test(List.of(2, 2, 2), 8);
- test(List.of(3, 3), 9);
- test(List.of(2, 5), 10);
- }
- private void test(List<Integer> l, int n) {
- List<Integer> factors = calculator.getFactors(n);
- assertIterableEquals(l, factors);
- }
- }
|