|
| 1 | +package com.thealgorithms.strings; |
| 2 | + |
| 3 | +import org.junit.jupiter.params.ParameterizedTest; |
| 4 | +import org.junit.jupiter.params.provider.MethodSource; |
| 5 | + |
| 6 | +import java.util.stream.Stream; |
| 7 | + |
| 8 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 9 | + |
| 10 | +class AlternativeStringArrangeTest { |
| 11 | + |
| 12 | + // Method to provide test data |
| 13 | + private static Stream<Object[]> provideTestData() { |
| 14 | + return Stream.of( |
| 15 | + new Object[]{"abc", "12345", "a1b2c345"}, |
| 16 | + new Object[]{"abcd", "12", "a1b2cd"}, |
| 17 | + new Object[]{"", "123", "123"}, |
| 18 | + new Object[]{"abc", "", "abc"}, |
| 19 | + new Object[]{"a", "1", "a1"}, |
| 20 | + new Object[]{"ab", "12", "a1b2"}, |
| 21 | + new Object[]{"abcdef", "123", "a1b2c3def"}, |
| 22 | + new Object[]{"ab", "123456", "a1b23456"} |
| 23 | + ); |
| 24 | + } |
| 25 | + |
| 26 | + // Parameterized test using the provided test data |
| 27 | + @ParameterizedTest(name = "{0} and {1} should return {2}") |
| 28 | + @MethodSource("provideTestData") |
| 29 | + void arrangeTest(String input1, String input2, String expected) { |
| 30 | + assertEquals(expected, AlternativeStringArrange.arrange(input1, input2)); |
| 31 | + } |
| 32 | +} |
0 commit comments