From 549444b63c6613082e708c5a0ae2e09ee19abdb0 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Wed, 10 Nov 2021 18:19:40 +0100 Subject: [PATCH] indexTest method added to TextTest --- docs/Äquivalenzklassen.md | 16 ++++++++++++++++ src/Text.java | 2 ++ src/TextEditor.java | 1 + test/TextTest.java | 39 ++++++++++++++++++++++++++++----------- 4 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 docs/Äquivalenzklassen.md diff --git a/docs/Äquivalenzklassen.md b/docs/Äquivalenzklassen.md new file mode 100644 index 0000000..15d6ca6 --- /dev/null +++ b/docs/Äquivalenzklassen.md @@ -0,0 +1,16 @@ +#Äquivalenzklassen + +### Text.java Index method + +|Positiv testcase|| +|:---|:---| +|1. Case|At least one Word gets used more than 3 times but not more than 3 times in one paragraph && at least one word doesn't get used more than 3 times in the whole text.| +|2. Case|At least one word gets used more than 3 times in only one paragraph çç at least one word doesn't get used more than 3 times in the whole text.| +|3. Case|The same word is been written in uppercase and lowercase and is been noticed as the same word.| +|4. Case|Punctuation marks and spaces are in the text| + +|Negativ testcase|| +|:---|:---| +|1. Case|Empty list of paragraphs| +|2. Case|Several punctuation marks and or spaces are been used behind| + diff --git a/src/Text.java b/src/Text.java index 57b18fb..303601c 100644 --- a/src/Text.java +++ b/src/Text.java @@ -172,10 +172,12 @@ public class Text { for (int i = 0; i < text.size(); i++) { String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><'/\n]+"); for (String word : words) { + //Words get formatted consistently counter = 1; firstLetter = word.substring(0, 1); restLetters = word.substring(1); word = firstLetter.toUpperCase() + restLetters; + //Words are beeing counted if (wordbook.containsKey(word)) { numbersList = wordbook.get(word); counter = numbersList.get(0); diff --git a/src/TextEditor.java b/src/TextEditor.java index bb87961..e9b9b48 100644 --- a/src/TextEditor.java +++ b/src/TextEditor.java @@ -3,6 +3,7 @@ public class TextEditor { public static void main(String[] args) { TextLogik t = new TextLogik(); + } } diff --git a/test/TextTest.java b/test/TextTest.java index 64516be..3536167 100644 --- a/test/TextTest.java +++ b/test/TextTest.java @@ -1,13 +1,11 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import java.util.ArrayList; -import java.util.HashMap; + public class TextTest { Text txt; - ArrayList sListe; @BeforeEach void setup() { @@ -33,15 +31,34 @@ public class TextTest { Assertions.assertEquals(4, txt.getText().size()); } + /** + * Test methode for Index method + */ @Test void indexTest() { - txt.add("Hallo ?Hallo> zusammen !test!"); - txt.add("Hallo, wie zusammen"); - txt.add("Hallo! Wie wie zusammen"); - sListe= txt.index(); - for (String str : sListe){ - System.out.println(str); - } - Assertions.assertEquals("Hallo 1, 2, 3",sListe.get(0)); + ArrayList stringListe; + + //Positiv Testcase One, Three and Four Negativ Testcase Two + txt.add("Word word Test"); + txt.add("Word word etc. !!test zweite... Zeile"); + txt.add("Lorem ipsum lorem ipsum TEST"); + stringListe = txt.index(); + Assertions.assertEquals("Word 1, 2",stringListe.get(0)); + Assertions.assertEquals("Test 1, 2, 3",stringListe.get(1)); + //End of Test + + setup(); + + //Positiv Testcase Two + txt.add("Word word Word Test"); + stringListe = txt.index(); + Assertions.assertEquals("Word 1",stringListe.get(0)); + //End of Test + + setup(); + + //Negativ Testcase One + stringListe = txt.index(); + Assertions.assertEquals(0,stringListe.size()); } }