WordWrapping with finite box height should throw when can’t fit

This commit is contained in:
Paul Campbell 2020-05-21 08:58:44 +01:00
parent 40b96a7662
commit ac9c497937

View file

@ -183,6 +183,26 @@ public class TextLineWrapTest
oneLinesWorthOfWords, oneLinesWorthOfWords,
WORD)); WORD));
} }
@Test
@DisplayName("Text fills the box")
public void textFillsBox() {
String lineOfWords = words(wordsPerLine, WORD);
String words = words(linesPerBox, lineOfWords);
assertThat(invoke(words).get(0))
.hasSize(linesPerBox)
.allSatisfy(line ->
assertThat(line).isEqualTo(lineOfWords));
}
@Test
@DisplayName("Text overflows the box")
public void tooManyLinesForBox() {
String lineOfWords = words(wordsPerLine, WORD);
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() ->
words(linesPerBox + 1, lineOfWords));
}
} }
@Nested @Nested