From 57d3760bfde8f7b693f3ef9715233b9346e2e97c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 27 May 2020 11:23:51 +0100 Subject: [PATCH] BoxFitter: throws NotEnoughSpace --- src/main/java/net/kemitix/text/fit/BoxFitterImpl.java | 2 +- src/test/java/net/kemitix/text/fit/BoxFitterTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java b/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java index 2606b8d..edc09e4 100644 --- a/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java +++ b/src/main/java/net/kemitix/text/fit/BoxFitterImpl.java @@ -44,7 +44,7 @@ class BoxFitterImpl implements BoxFitter { new FitEnvironment(text, fontFactory, graphics2D, boxes)); if (fit <= 2) { - throw new IllegalArgumentException("The text is too long to fit"); + throw new NotEnoughSpace(0); } return fit; } diff --git a/src/test/java/net/kemitix/text/fit/BoxFitterTest.java b/src/test/java/net/kemitix/text/fit/BoxFitterTest.java index 5f39e9a..0db6b55 100644 --- a/src/test/java/net/kemitix/text/fit/BoxFitterTest.java +++ b/src/test/java/net/kemitix/text/fit/BoxFitterTest.java @@ -89,11 +89,11 @@ public class BoxFitterTest } @Test - @DisplayName("Text too long to fit throws and exception") + @DisplayName("Text too long to fit throws") // too long to fit means it would need to be rendered at a font size of <2 public void tooLongThrows() { String longText = longStringGenerator(197); - assertThatExceptionOfType(IllegalArgumentException.class) + assertThatExceptionOfType(NotEnoughSpace.class) .isThrownBy(() -> fit(longText)); }