mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
* LongestPalindromicSubstring * fix Rule:CollapsibleIfStatements --------- Co-authored-by: alxkm <alx@alx.com>
22 lines
866 B
Java
22 lines
866 B
Java
package com.thealgorithms.strings;
|
|
|
|
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;
|
|
|
|
class LongestPalindromicSubstringTest {
|
|
|
|
@ParameterizedTest
|
|
@MethodSource("provideTestCasesForLongestPalindrome")
|
|
void testLongestPalindrome(String input, String expected) {
|
|
assertEquals(expected, LongestPalindromicSubstring.longestPalindrome(input));
|
|
}
|
|
|
|
private static Stream<Arguments> provideTestCasesForLongestPalindrome() {
|
|
return Stream.of(Arguments.of("babad", "bab"), Arguments.of("cbbd", "bb"), Arguments.of("a", "a"), Arguments.of("", ""), Arguments.of("abc", "a"), Arguments.of(null, ""), Arguments.of("aaaaa", "aaaaa"));
|
|
}
|
|
}
|