/
NikolayIvkin
/
TheAlgorithms
Обзор
Документация
Войти
/
NikolayIvkin
/
TheAlgorithms
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/test/java/com/thealgorithms/maths/CollatzConjectureTest.java
41 строка
1 KB
Piotr Idzik
style: enable `AvoidStarImport` in checkstyle (#5141)
05 май 2024, 21:48
Не верифицирован
05 май 2024, 21:48
414835d
Код
Авторство
О чём код?
package com.thealgorithms.maths; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertIterableEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.List; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; class CollatzConjectureTest { static CollatzConjecture cConjecture; @BeforeAll static void setUp() { cConjecture = new CollatzConjecture(); } @Test void nextNumberFromEvenNumber() { assertEquals(25, cConjecture.nextNumber(50)); } @Test void nextNumberFromOddNumber() { assertEquals(154, cConjecture.nextNumber(51)); } @Test void collatzConjecture() { final List<Integer> expected = List.of(35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1); assertIterableEquals(expected, cConjecture.collatzConjecture(35)); } @Test void sequenceOfNotNaturalFirstNumber() { assertThrows(IllegalArgumentException.class, () -> cConjecture.collatzConjecture(0)); assertThrows(IllegalArgumentException.class, () -> cConjecture.collatzConjecture(-1)); } }