Solution { public List<String> fullJustify(String[] words, int maxWidth) { List<String> output = new ArrayList<>(); int exclusiveStop = 0; int start = 0; while (exclusiveStop < words.length) { exclusiveStop = exclusiveStop(words, start, maxWidth); output.add(justifyLine(words, maxWidth, start, exclusiveStop)); start = exclusiveStop; } return output; }  List<String> fullJustify(String[] words, int maxWidth);  }
@Test public void testFullJustify_withASingleWord() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "justification." }, 16); assertEquals(Arrays.asList("justification. "), result); }
@Test public void testFullJustify_withAFullLineSingleWord() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "0123456789ABCDE." }, 16); assertEquals(Arrays.asList("0123456789ABCDE."), result); }
@Test public void testFullJustify_MoreWords() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "This", "is", "an", "example", "of", "text", "justification." }, 16); assertEquals(Arrays.asList("This is an", "example of text", "justification. "), result); }
@Test public void testFullJustify_SingleLetter() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "a", "b", "c" }, 1); assertEquals(Arrays.asList("a", "b", "c"), result); }
@Test public void testFullJustify_LastLineHaveMoreWords() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "What", "must", "be", "shall", "be." }, 12); assertEquals(Arrays.asList("What must be", "shall be. "), result); }
@Test public void testFullJustify_WithEmptyWord() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "" }, 2); assertEquals(Arrays.asList(" "), result); }
@Test public void testFullJustify_WithMiddleLineContainingOnlyOneLetter() { Solution solution = new Solution(); List<String> result = solution.fullJustify(new String[] { "hello", ",", "world" }, 5); assertEquals(Arrays.asList("hello", ", ", "world"), result); }