/
NikolayIvkin
/
TheAlgorithms
Обзор
Документация
Войти
/
NikolayIvkin
/
TheAlgorithms
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/test/java/com/thealgorithms/dynamicprogramming/LongestAlternatingSubsequenceTest.java
22 строки
1 KB
Alex Klymenko
test: `LongestAlternatingSubsequenceTest` (#5399)
26 авг 2024, 09:37
Не верифицирован
26 авг 2024, 09:37
6edc009
Код
Авторство
О чём код?
package com.thealgorithms.dynamicprogramming; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; public class LongestAlternatingSubsequenceTest { @ParameterizedTest @MethodSource("provideTestCases") void testAlternatingLength(int[] arr, int expected) { assertEquals(expected, LongestAlternatingSubsequence.alternatingLength(arr, arr.length)); } private static Stream<Arguments> provideTestCases() { return Stream.of(Arguments.of(new int[] {1}, 1), Arguments.of(new int[] {1, 2}, 2), Arguments.of(new int[] {2, 1}, 2), Arguments.of(new int[] {1, 3, 2, 4, 3, 5}, 6), Arguments.of(new int[] {1, 2, 3, 4, 5}, 2), Arguments.of(new int[] {5, 4, 3, 2, 1}, 2), Arguments.of(new int[] {10, 22, 9, 33, 49, 50, 31, 60}, 6), Arguments.of(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 2)); } }