PrimeFactorsCalculatorTest.java 997 B

1234567891011121314151617181920212223242526272829303132333435
  1. import org.example.PrimeFactorsCalculator;
  2. import org.junit.jupiter.api.Test;
  3. import java.util.List;
  4. import static java.util.Collections.EMPTY_LIST;
  5. import static org.junit.jupiter.api.Assertions.assertIterableEquals;
  6. public class PrimeFactorsCalculatorTest {
  7. private PrimeFactorsCalculator calculator = new PrimeFactorsCalculator();
  8. @Test
  9. void testGetFactorsValue1(){
  10. List<Integer> factors = calculator.getFactors(1);
  11. test(EMPTY_LIST,1);
  12. }
  13. @Test
  14. void testGetFactorsValues2() {
  15. test(List.of(2, 2), 4);
  16. test(List.of(2), 2);
  17. test(List.of(3), 3);
  18. test(List.of(2, 2), 4);
  19. test(List.of(5), 5);
  20. test(List.of(2, 3), 6);
  21. test(List.of(7), 7);
  22. test(List.of(2, 2, 2), 8);
  23. test(List.of(3, 3), 9);
  24. test(List.of(2, 5), 10);
  25. }
  26. private void test(List<Integer> l, int n) {
  27. List<Integer> factors = calculator.getFactors(n);
  28. assertIterableEquals(l, factors);
  29. }
  30. }