From cfafd92f7bb56b7f825b8652c750ee1ab34f9eef Mon Sep 17 00:00:00 2001 From: amadoste Date: Fri, 12 Nov 2021 11:11:03 +0100 Subject: [PATCH] Added Javadoc to test files. --- ...ruppe06-hufflepuff-projekt2-texteditor.iml | 16 ++++++++++++++ src/TextOutput.java | 21 ++++++++----------- test/TextOutputTest.java | 16 ++++++++++---- test/TextTest.java | 11 ++++++++-- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/.idea/gruppe06-hufflepuff-projekt2-texteditor.iml b/.idea/gruppe06-hufflepuff-projekt2-texteditor.iml index 0fb1519..324ad0a 100644 --- a/.idea/gruppe06-hufflepuff-projekt2-texteditor.iml +++ b/.idea/gruppe06-hufflepuff-projekt2-texteditor.iml @@ -24,5 +24,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/TextOutput.java b/src/TextOutput.java index 625abb8..16d577a 100644 --- a/src/TextOutput.java +++ b/src/TextOutput.java @@ -17,10 +17,9 @@ public class TextOutput { * @param text the ArrayList which is then formatted into the desired output. */ public void print(ArrayList text) { - if(text.size() == 0) { + if (text.size() == 0) { errorMissingText(); - } - else if (formatRaw) { + } else if (formatRaw) { printFormated(text); } else { toFormat(text); @@ -50,15 +49,15 @@ public class TextOutput { String[] words = paragraph.split(" "); int lastWordNumber = words.length; int currentWordNumber = 0; - for(String word : words) { + for (String word : words) { currentWordNumber++; - if (word.length()>= columnWidth - currentLength && currentWordNumber != 1) { + if (word.length() >= columnWidth - currentLength && currentWordNumber != 1) { System.out.println(); currentLength = 0; } System.out.print(word); - if(!(currentWordNumber == lastWordNumber)) { + if (!(currentWordNumber == lastWordNumber)) { System.out.print(" "); currentLength = currentLength + word.length() + 1; } else { @@ -86,12 +85,11 @@ public class TextOutput { * @param length the paragraph length when printing the text. */ public void formatFix(int length) { - if(length > 0) { + if (length > 0) { formatRaw = false; columnWidth = length; userInfoOutput("Command was successful"); - } - else { + } else { System.err.println("Minimum length has to be greater than 0"); } } @@ -111,10 +109,9 @@ public class TextOutput { * @param index ArrayList with words and in which part they have */ public void indexOutput(ArrayList index) { - if(index.size() == 0) { + if (index.size() == 0) { userInfoOutput("index empty"); - } - else { + } else { for (String word : index) { System.out.println(word); } diff --git a/test/TextOutputTest.java b/test/TextOutputTest.java index 17d72b9..d417818 100644 --- a/test/TextOutputTest.java +++ b/test/TextOutputTest.java @@ -4,26 +4,34 @@ import org.junit.jupiter.api.Test; import java.util.ArrayList; +/** + * New class TextOutputTest + * This class is here to test the class TextOutput and to test the console output of that class. + * Author: Leonardo Brandenberger + * Date: 12.11.2021 + */ class TextOutputTest { TextOutput textOutput; ArrayList text; + /** + * This method is here as a preparation for the test. + */ @BeforeEach public void setup() { textOutput = new TextOutput(); textOutput.formatFix(20); - //textOutput.formatRaw(); text = new ArrayList<>(); text.add("Virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, septentr ionesimmensoslongusw ordos."); text.add("Virtutedasjdhashdkjhakjdhakdshjkashd praecedunt, quod fere cotidianis proeliis cum"); - //text.add("ordos."); text.add("1234"); text.add("12417575147517845 445264565"); text.add(" "); - //text.add("1eeeeeee8597389751"); - //text.add("TextTextTextTextTextTextTextTextTextTextTextTextTextText TextTextTextTextTextTextTextTextTextTextTextText TextTextText"); } + /** + * This method is the test to show if the console output works as we expect it to. + */ @Test public void print() { textOutput.print(text); diff --git a/test/TextTest.java b/test/TextTest.java index 376dc42..b1049de 100644 --- a/test/TextTest.java +++ b/test/TextTest.java @@ -3,10 +3,18 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.ArrayList; - +/** + * New class TextTest + * This class is here to test the different methods of the Text class. + * Author: Roman Schenk, Andrin Fassbind + * Date: 12.11.2021 + */ public class TextTest { Text txt; + /** + * This method is here as a preparation for the test. + */ @BeforeEach void setup() { txt = new Text(); @@ -32,7 +40,6 @@ public class TextTest { } /** - * * Test Method del */ @Test