|
| 1 | +package com.fishercoder; |
| 2 | + |
| 3 | +import com.fishercoder.solutions._140; |
| 4 | +import org.junit.jupiter.api.BeforeEach; |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | + |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.Arrays; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 12 | + |
| 13 | + |
| 14 | +public class _140Test { |
| 15 | + private static _140.Solution1 solution1; |
| 16 | + private static String s; |
| 17 | + private static List<String> wordDict; |
| 18 | + |
| 19 | + @BeforeEach |
| 20 | + public void setup() { |
| 21 | + solution1 = new _140.Solution1(); |
| 22 | + } |
| 23 | + |
| 24 | + @Test |
| 25 | + public void test1() { |
| 26 | + s = "catsanddog"; |
| 27 | + wordDict = new ArrayList<>(Arrays.asList("cat", "cats", "and", "sand", "dog")); |
| 28 | + List<String> actual = solution1.wordBreak(s, wordDict); |
| 29 | + List<String> expected = Arrays.asList("cats and dog", "cat sand dog"); |
| 30 | + //assert equals ignoring order |
| 31 | + assertTrue(expected.size() == actual.size() && actual.containsAll(expected) && expected.containsAll(actual)); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + public void test2() { |
| 36 | + s = "pineapplepenapple"; |
| 37 | + wordDict = new ArrayList<>(Arrays.asList("apple", "pen", "applepen", "pine", "pineapple")); |
| 38 | + List<String> actual = solution1.wordBreak(s, wordDict); |
| 39 | + List<String> expected = Arrays.asList("pine apple pen apple", "pineapple pen apple", "pine applepen apple"); |
| 40 | + //assert equals ignoring order |
| 41 | + assertTrue(expected.size() == actual.size() && actual.containsAll(expected) && expected.containsAll(actual)); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void test3() { |
| 46 | + s = "catsandog"; |
| 47 | + wordDict = new ArrayList<>(Arrays.asList("cats", "dog", "sand", "and", "cat")); |
| 48 | + List<String> actual = solution1.wordBreak(s, wordDict); |
| 49 | + List<String> expected = Arrays.asList(); |
| 50 | + //assert equals ignoring order |
| 51 | + assertTrue(expected.size() == actual.size() && actual.containsAll(expected) && expected.containsAll(actual)); |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments