BoxFitter: throws NotEnoughSpace

This commit is contained in:
Paul Campbell 2020-05-27 11:23:51 +01:00
parent e9b3ba39e1
commit 57d3760bfd
2 changed files with 3 additions and 3 deletions

View file

@ -44,7 +44,7 @@ class BoxFitterImpl implements BoxFitter {
new FitEnvironment(text, fontFactory, graphics2D, new FitEnvironment(text, fontFactory, graphics2D,
boxes)); boxes));
if (fit <= 2) { if (fit <= 2) {
throw new IllegalArgumentException("The text is too long to fit"); throw new NotEnoughSpace(0);
} }
return fit; return fit;
} }

View file

@ -89,11 +89,11 @@ public class BoxFitterTest
} }
@Test @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 // too long to fit means it would need to be rendered at a font size of <2
public void tooLongThrows() { public void tooLongThrows() {
String longText = longStringGenerator(197); String longText = longStringGenerator(197);
assertThatExceptionOfType(IllegalArgumentException.class) assertThatExceptionOfType(NotEnoughSpace.class)
.isThrownBy(() -> fit(longText)); .isThrownBy(() -> fit(longText));
} }