Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/kyu6/WhichAreIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static String[] inArray(String[] array1, String[] array2) {
return Stream.of(array1)
.filter(word -> Stream.of(array2)
.anyMatch(bigWord -> bigWord.contains(word)))
.distinct()
.sorted().toList()
.toArray(String[]::new);
}
Expand Down
49 changes: 32 additions & 17 deletions src/test/java/kyu6/WhichAreInTest.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
package kyu6;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import org.junit.jupiter.api.Tag;
import java.util.*;
import java.util.stream.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
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.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import net.jqwik.api.Property;
import net.jqwik.api.ForAll;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static kyu6.WhichAreIn.*;

@Tag("smoke")
public class WhichAreInTest {
class WhichAreInTest {

@Test
void smokeTestsShouldExecuteApi() {
quality.SmokeMethodTestHarness.verify(kyu6.WhichAreIn.class);
quality.SmokeMethodTestHarness.verify(WhichAreIn.class);
}

@Test
void shouldReturnSortedSubstringsFromTheKataExample() {
String[] a1 = {"live", "arp", "strong"};
String[] a2 = {"lively", "alive", "harp", "sharp", "armstrong"};

assertArrayEquals(new String[]{"arp", "live", "strong"}, WhichAreIn.inArray(a1, a2));
}

@Test
void shouldReturnEmptyArrayWhenNothingIsContained() {
String[] a1 = {"tarp", "mice", "bull"};
String[] a2 = {"lively", "alive", "harp", "sharp", "armstrong"};

assertArrayEquals(new String[0], WhichAreIn.inArray(a1, a2));
}

@Test
void shouldNotRepeatWordsThatOccurTwiceInTheFirstArray() {
String[] a1 = {"arp", "live", "strong", "arp", "live"};
String[] a2 = {"lively", "alive", "harp", "sharp", "armstrong"};

assertArrayEquals(new String[]{"arp", "live", "strong"}, WhichAreIn.inArray(a1, a2));
}
}