Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
1cc559b416
File diff suppressed because one or more lines are too long
|
@ -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|
|
||||
|
|
@ -6,7 +6,6 @@ public class Text {
|
|||
|
||||
private final ArrayList<String> text = new ArrayList<>();
|
||||
private static final String dummyText = "The standard Lorem Ipsum passage, used since the 1500s \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\" Section 1.10.32 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
|
||||
private HashMap<String, ArrayList<Integer>> wordbook = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Method to check if a specific Paragraph exists
|
||||
|
@ -136,7 +135,7 @@ public class Text {
|
|||
* @return ArrayList<String>
|
||||
*/
|
||||
public ArrayList<String> index() {
|
||||
wordbook = createWordlist();
|
||||
HashMap<String,ArrayList<Integer>> wordbook = createWordlist();
|
||||
String input;
|
||||
ArrayList<String> output = new ArrayList<>();
|
||||
ArrayList<Integer> values;
|
||||
|
@ -165,6 +164,7 @@ public class Text {
|
|||
* @return HashMap<String, ArrayList < Integer>>
|
||||
*/
|
||||
private HashMap<String, ArrayList<Integer>> createWordlist() {
|
||||
HashMap<String,ArrayList<Integer>> wordbook = new HashMap<>();
|
||||
int counter;
|
||||
ArrayList<Integer> numbersList;
|
||||
String firstLetter;
|
||||
|
@ -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);
|
||||
|
|
|
@ -3,6 +3,7 @@ public class TextEditor {
|
|||
|
||||
public static void main(String[] args) {
|
||||
TextLogik t = new TextLogik();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,11 @@ public class TextLogik {
|
|||
private final Text text;
|
||||
private final TextOutput textOutput;
|
||||
|
||||
/**
|
||||
* Initiates a new instance of the class TextLogik.
|
||||
* Contains command instructions for the class Text.
|
||||
* Defined the different cases and appointed to specific commands.
|
||||
*/
|
||||
public TextLogik() {
|
||||
text = new Text();
|
||||
textOutput = new TextOutput();
|
||||
|
@ -79,6 +84,12 @@ public class TextLogik {
|
|||
} while (!"EXIT".equals(command[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if a command is numeric.
|
||||
*
|
||||
* @param str command that should be a number.
|
||||
* @return true if the given str matches.
|
||||
*/
|
||||
private boolean isNumeric(String str) {
|
||||
return str.matches("\\d+");
|
||||
}
|
||||
|
|
|
@ -1,28 +1,95 @@
|
|||
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<String> sListe;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
txt = new Text();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Method for add and dummy methods
|
||||
*/
|
||||
@Test
|
||||
void addTest() {
|
||||
Assertions.assertEquals(0, txt.getText().size());
|
||||
Assertions.assertEquals(false, txt.add(1, "test"));
|
||||
Assertions.assertEquals(false, txt.dummy(1));
|
||||
Assertions.assertEquals(0, txt.getText().size());
|
||||
Assertions.assertEquals(true, txt.add("test1"));
|
||||
Assertions.assertEquals(true, txt.add(1, "test2"));
|
||||
Assertions.assertEquals("test2", txt.getText().get(0));
|
||||
Assertions.assertEquals("test1", txt.getText().get(1));
|
||||
Assertions.assertEquals(true, txt.dummy(2));
|
||||
Assertions.assertEquals(true, txt.dummy());
|
||||
Assertions.assertEquals(true, txt.getText().get(1).equals(txt.getText().get(3)));
|
||||
Assertions.assertEquals(4, txt.getText().size());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Test Method del
|
||||
*/
|
||||
@Test
|
||||
void del() {
|
||||
Assertions.assertEquals(true, txt.add("Das ist der erste Beispiel Text."));
|
||||
Assertions.assertEquals(true, txt.add("Das ist der zweite Beispiel Text."));
|
||||
Assertions.assertEquals(true, txt.add("Das ist der dritte Beispiel Text."));
|
||||
Assertions.assertEquals(true, txt.add("Das ist der vierte Beispiel Text."));
|
||||
Assertions.assertEquals(false, txt.del(5));
|
||||
Assertions.assertEquals(true, txt.del(2));
|
||||
Assertions.assertEquals(true, txt.del());
|
||||
Assertions.assertEquals("Das ist der erste Beispiel Text.", txt.getText().get(0));
|
||||
Assertions.assertEquals("Das ist der dritte Beispiel Text.", txt.getText().get(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Method for replace Method
|
||||
*/
|
||||
@Test
|
||||
void replace() {
|
||||
Assertions.assertEquals(true, txt.add("Das ist der erste Beispiel Text."));
|
||||
Assertions.assertEquals(true, txt.add("Das ist der zweite Beispiel Text."));
|
||||
Assertions.assertEquals(false, txt.replace(3, "alt", "neu"));
|
||||
Assertions.assertEquals(true, txt.replace(1, "erste", "zweite"));
|
||||
Assertions.assertEquals(true, txt.replace("zweite", "erste"));
|
||||
Assertions.assertEquals("Das ist der zweite Beispiel Text.", txt.getText().get(0));
|
||||
Assertions.assertEquals("Das ist der erste Beispiel Text.", txt.getText().get(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<String> 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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue