gruppe06-hufflepuff-projekt.../test/TextTest.java

48 lines
1.5 KiB
Java

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
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));
}
}