From a3b6388c9ef353c568ee1ac8a27eaf658847eb93 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 5 Nov 2021 18:25:20 +0100 Subject: [PATCH] fixed error win unformatedtext class that resulted in println before each word. --- src/TextOutput.java | 2 +- test/TextOutputTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TextOutput.java b/src/TextOutput.java index f9ccee9..062c8c1 100644 --- a/src/TextOutput.java +++ b/src/TextOutput.java @@ -47,7 +47,7 @@ public class TextOutput { } else { - if (word.length() >= columnWidth - currentLength) { + if (word.length() >= columnWidth - currentLength && !(currentLength == 0)) { currentLength = 0; System.out.println(); } diff --git a/test/TextOutputTest.java b/test/TextOutputTest.java index 341cd8f..e3863aa 100644 --- a/test/TextOutputTest.java +++ b/test/TextOutputTest.java @@ -15,11 +15,12 @@ class TextOutputTest { public void setup(){ textOutput = new TextOutput(); textOutput.formatFix(9); - textOutput.formatRaw(); + //textOutput.formatRaw(); text = new ArrayList<>(); text.add("123456789"); text.add("1234"); text.add("12 12 12"); + text.add(" "); text.add("1eeeeeee8597389751"); text.add("TextTextTextTextTextTextTextTextTextTextTextTextTextText TextTextTextTextTextTextTextTextTextTextTextText TextTextText"); }