Added Javadoc to test files.
This commit is contained in:
parent
ac8f8218d4
commit
cfafd92f7b
|
@ -24,5 +24,21 @@
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library" scope="TEST">
|
||||||
|
<library name="JUnit5.7.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -17,10 +17,9 @@ public class TextOutput {
|
||||||
* @param text the ArrayList which is then formatted into the desired output.
|
* @param text the ArrayList which is then formatted into the desired output.
|
||||||
*/
|
*/
|
||||||
public void print(ArrayList<String> text) {
|
public void print(ArrayList<String> text) {
|
||||||
if(text.size() == 0) {
|
if (text.size() == 0) {
|
||||||
errorMissingText();
|
errorMissingText();
|
||||||
}
|
} else if (formatRaw) {
|
||||||
else if (formatRaw) {
|
|
||||||
printFormated(text);
|
printFormated(text);
|
||||||
} else {
|
} else {
|
||||||
toFormat(text);
|
toFormat(text);
|
||||||
|
@ -50,15 +49,15 @@ public class TextOutput {
|
||||||
String[] words = paragraph.split(" ");
|
String[] words = paragraph.split(" ");
|
||||||
int lastWordNumber = words.length;
|
int lastWordNumber = words.length;
|
||||||
int currentWordNumber = 0;
|
int currentWordNumber = 0;
|
||||||
for(String word : words) {
|
for (String word : words) {
|
||||||
currentWordNumber++;
|
currentWordNumber++;
|
||||||
if (word.length()>= columnWidth - currentLength && currentWordNumber != 1) {
|
if (word.length() >= columnWidth - currentLength && currentWordNumber != 1) {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
currentLength = 0;
|
currentLength = 0;
|
||||||
}
|
}
|
||||||
System.out.print(word);
|
System.out.print(word);
|
||||||
|
|
||||||
if(!(currentWordNumber == lastWordNumber)) {
|
if (!(currentWordNumber == lastWordNumber)) {
|
||||||
System.out.print(" ");
|
System.out.print(" ");
|
||||||
currentLength = currentLength + word.length() + 1;
|
currentLength = currentLength + word.length() + 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,12 +85,11 @@ public class TextOutput {
|
||||||
* @param length the paragraph length when printing the text.
|
* @param length the paragraph length when printing the text.
|
||||||
*/
|
*/
|
||||||
public void formatFix(int length) {
|
public void formatFix(int length) {
|
||||||
if(length > 0) {
|
if (length > 0) {
|
||||||
formatRaw = false;
|
formatRaw = false;
|
||||||
columnWidth = length;
|
columnWidth = length;
|
||||||
userInfoOutput("Command was successful");
|
userInfoOutput("Command was successful");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
System.err.println("Minimum length has to be greater than 0");
|
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
|
* @param index ArrayList with words and in which part they have
|
||||||
*/
|
*/
|
||||||
public void indexOutput(ArrayList<String> index) {
|
public void indexOutput(ArrayList<String> index) {
|
||||||
if(index.size() == 0) {
|
if (index.size() == 0) {
|
||||||
userInfoOutput("index empty");
|
userInfoOutput("index empty");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (String word : index) {
|
for (String word : index) {
|
||||||
System.out.println(word);
|
System.out.println(word);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,26 +4,34 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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 {
|
class TextOutputTest {
|
||||||
TextOutput textOutput;
|
TextOutput textOutput;
|
||||||
ArrayList<String> text;
|
ArrayList<String> text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is here as a preparation for the test.
|
||||||
|
*/
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
textOutput = new TextOutput();
|
textOutput = new TextOutput();
|
||||||
textOutput.formatFix(20);
|
textOutput.formatFix(20);
|
||||||
//textOutput.formatRaw();
|
|
||||||
text = new ArrayList<>();
|
text = new ArrayList<>();
|
||||||
text.add("Virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, septentr ionesimmensoslongusw ordos.");
|
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("Virtutedasjdhashdkjhakjdhakdshjkashd praecedunt, quod fere cotidianis proeliis cum");
|
||||||
//text.add("ordos.");
|
|
||||||
text.add("1234");
|
text.add("1234");
|
||||||
text.add("12417575147517845 445264565");
|
text.add("12417575147517845 445264565");
|
||||||
text.add(" ");
|
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
|
@Test
|
||||||
public void print() {
|
public void print() {
|
||||||
textOutput.print(text);
|
textOutput.print(text);
|
||||||
|
|
|
@ -3,10 +3,18 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
public class TextTest {
|
||||||
Text txt;
|
Text txt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is here as a preparation for the test.
|
||||||
|
*/
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
void setup() {
|
||||||
txt = new Text();
|
txt = new Text();
|
||||||
|
@ -32,7 +40,6 @@ public class TextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Test Method del
|
* Test Method del
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue