indexTest method added to TextTest

This commit is contained in:
Andrin Fassbind 2021-11-10 18:19:40 +01:00
parent 77cabcf39a
commit 549444b63c
4 changed files with 47 additions and 11 deletions

View File

@ -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|

View File

@ -172,10 +172,12 @@ public class Text {
for (int i = 0; i < text.size(); i++) { for (int i = 0; i < text.size(); i++) {
String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><'/\n]+"); String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><'/\n]+");
for (String word : words) { for (String word : words) {
//Words get formatted consistently
counter = 1; counter = 1;
firstLetter = word.substring(0, 1); firstLetter = word.substring(0, 1);
restLetters = word.substring(1); restLetters = word.substring(1);
word = firstLetter.toUpperCase() + restLetters; word = firstLetter.toUpperCase() + restLetters;
//Words are beeing counted
if (wordbook.containsKey(word)) { if (wordbook.containsKey(word)) {
numbersList = wordbook.get(word); numbersList = wordbook.get(word);
counter = numbersList.get(0); counter = numbersList.get(0);

View File

@ -3,6 +3,7 @@ public class TextEditor {
public static void main(String[] args) { public static void main(String[] args) {
TextLogik t = new TextLogik(); TextLogik t = new TextLogik();
} }
} }

View File

@ -1,13 +1,11 @@
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
public class TextTest { public class TextTest {
Text txt; Text txt;
ArrayList<String> sListe;
@BeforeEach @BeforeEach
void setup() { void setup() {
@ -33,15 +31,34 @@ public class TextTest {
Assertions.assertEquals(4, txt.getText().size()); Assertions.assertEquals(4, txt.getText().size());
} }
/**
* Test methode for Index method
*/
@Test @Test
void indexTest() { void indexTest() {
txt.add("Hallo ?Hallo> zusammen !test!"); ArrayList<String> stringListe;
txt.add("Hallo, wie zusammen");
txt.add("Hallo! Wie wie zusammen"); //Positiv Testcase One, Three and Four Negativ Testcase Two
sListe= txt.index(); txt.add("Word word Test");
for (String str : sListe){ txt.add("Word word etc. !!test zweite... Zeile");
System.out.println(str); txt.add("Lorem ipsum lorem ipsum TEST");
} stringListe = txt.index();
Assertions.assertEquals("Hallo 1, 2, 3",sListe.get(0)); 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());
} }
} }