/
NikolayIvkin
/
TheAlgorithms
Обзор
Документация
Войти
/
NikolayIvkin
/
TheAlgorithms
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/test/java/com/thealgorithms/maths/FactorialRecursionTest.java
27 строк
955 B
marysiuniq
Added tests for `FactorialRecursion` (#5109)
20 апр 2024, 21:31
Не верифицирован
20 апр 2024, 21:31
8129686
Код
Авторство
О чём код?
package com.thealgorithms.maths; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; public class FactorialRecursionTest { @ParameterizedTest @MethodSource("inputStream") void testFactorialRecursion(long expected, int number) { assertEquals(expected, FactorialRecursion.factorial(number)); } private static Stream<Arguments> inputStream() { return Stream.of(Arguments.of(1, 0), Arguments.of(1, 1), Arguments.of(2, 2), Arguments.of(6, 3), Arguments.of(120, 5)); } @Test void testThrowsForNegativeInput() { assertThrows(IllegalArgumentException.class, () -> FactorialRecursion.factorial(-1)); } }