C3PO Test

master
Eline 2023-01-09 13:55:50 +01:00
parent 48a7b45a65
commit e03596ecf2
1 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,68 @@
package test.java.roboter;
import org.junit.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DynamicNode;
import roboter.exceptions.RobotException;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Properties;
public class C3POTest <SystemOutRule, OutputCapture> {
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
private final ByteArrayOutputStream err = new ByteArrayOutputStream();
private final PrintStream originalOut = System.out;
private final PrintStream originalErr = System.err;
@Before
public void setStreams() {
System.setOut(new PrintStream(out));
System.setErr(new PrintStream(err));
}
@After
public void restoreInitialStreams() {
System.setOut(originalOut);
System.setErr(originalErr);
}
@Test
public void sortieren() throws RobotException {
var list = new int[]{12,6,7,10,18,2};
Robot robot= RobotFactory.getRobot(Typ.C3PO,"roboter1");
Assert.assertEquals("18,12,10,7,6,2",robot.speak(list));
var list1 = new int[] {17,10,19,1,4,2,7};
Assert.assertEquals("19,17,10,7,4,2,1", robot.speak(list));
var list2 = new int[] {3,17,7,20,5,15,8};
Assert.assertEquals("20,17,15,8,7,5,3", robot.speak(list));
var list3 = new int[] {13,8,5,12,1,9,7};
Assert.assertEquals("13,12,9,8,7,5,1", robot.speak(list));
var list4 = new int[] {18,4,21,7,3,2,9};
Assert.assertEquals("21,18,9,7,4,3,2", robot.speak(list));
var list5 = new int[] {13,23,8,4,22,6};
Assert.assertEquals("23,22,13,8,6,4", robot.speak(list));
var list6 = new int[] {10,9,8,7,6,5};
Assert.assertEquals("10,9,8,7,6,5", robot.speak(list));
var list7 = new int[] {1,2,3,5,4,6};
Assert.assertEquals("6,5,4,3,2,1", robot.speak(list));
var list8 = new int[] {20,19,18,17,16,15};
Assert.assertEquals("20,19,18,17,16,15", robot.speak(list));
var list9 = new int[] {15,1,13,10,7,4};
Assert.assertEquals("15,13,10,7,4,1", robot.speak(list));
var list10 = new int[] {10,15,11,8,5,6,};
Assert.assertEquals("15,11,10,8,6,5", robot.speak(list));
}
}