From ac9c497937ad185698c33863638a4a64e7c8fed8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 21 May 2020 08:58:44 +0100 Subject: [PATCH] =?UTF-8?q?WordWrapping=20with=20finite=20box=20height=20s?= =?UTF-8?q?hould=20throw=20when=20can=E2=80=99t=20fit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kemitix/text/fit/TextLineWrapTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/net/kemitix/text/fit/TextLineWrapTest.java b/src/test/java/net/kemitix/text/fit/TextLineWrapTest.java index 62dd328..e4f14bf 100644 --- a/src/test/java/net/kemitix/text/fit/TextLineWrapTest.java +++ b/src/test/java/net/kemitix/text/fit/TextLineWrapTest.java @@ -183,6 +183,26 @@ public class TextLineWrapTest oneLinesWorthOfWords, 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