Skip to content
Snippets Groups Projects
Commit 94d9eb2d authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Updated starter code per revisions to the scope of the homework and to improve...

Updated starter code per revisions to the scope of the homework and to improve some autogenerated test case names.
parent b9e9e54d
No related branches found
No related tags found
No related merge requests found
package edu.unl.cse.soft160.conditionals;
import java.util.Scanner;
public class Scramble {
public static void main(String... arguments) {
// [write code here]
}
}
......@@ -34,49 +34,49 @@ public class SatelliteTest extends TestCase {
return collector.toString();
}
public void testCaseZero() {
public void testAcquireWithNoRotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Continue tracking"), runMain("no", "no", "no"));
+ "Continue"), runMain("no", "no", "no"));
}
public void testCaseOne() {
public void testAcquireWithSTTRotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Continue tracking"), runMain("no", "no", "yes"));
+ "Continue"), runMain("no", "no", "yes"));
}
public void testCaseTwo() {
public void testAcquireWithIRURotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Continue tracking"), runMain("no", "yes", "no"));
+ "Continue"), runMain("no", "yes", "no"));
}
public void testCaseThree() {
public void testAcquireWithRotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Continue tracking"), runMain("no", "yes", "yes"));
+ "Continue"), runMain("no", "yes", "yes"));
}
public void testCaseFour() {
public void testTrackWithNoRotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Continue tracking"), runMain("yes", "no", "no"));
+ "Continue"), runMain("yes", "no", "no"));
}
public void testCaseFive() {
public void testTrackWithSTTRotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Counteract rotation"), runMain("yes", "no", "yes"));
}
public void testCaseSix() {
public void testTrackWithIRURotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Counteract rotation"), runMain("yes", "yes", "no"));
}
public void testCaseSeven() {
public void testTrackWithRotation() {
assertEquals(assemble("Is the satellite in tracking mode rather than acquire mode (yes/no)? "
+ "Does the IRU report rotation (yes/no)? " + "Does the STT report rotation (yes/no)? "
+ "Counteract rotation"), runMain("yes", "yes", "yes"));
......
package edu.unl.cse.soft160.conditionals;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.PrintStream;
import java.io.ByteArrayOutputStream;
public class ScrambleTest extends TestCase {
public ScrambleTest(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(ScrambleTest.class);
}
protected static String assemble(String... lines) {
return String.join("\n", lines) + "\n";
}
protected static String runMain(String... inputs) {
InputStream in = System.in;
PrintStream out = System.out;
System.setIn(new ByteArrayInputStream(assemble(inputs).getBytes()));
ByteArrayOutputStream collector = new ByteArrayOutputStream();
System.setOut(new PrintStream(collector));
Scramble.main();
System.setIn(in);
System.setOut(out);
return collector.toString();
}
public void testOrder0() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 2."),
runMain("0", "1", "2"));
}
public void testOrder1() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 2."),
runMain("0", "2", "1"));
}
public void testOrder2() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 2."),
runMain("2", "0", "1"));
}
public void testOrder3() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 2."),
runMain("2", "1", "0"));
}
public void testOrder4() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 2."),
runMain("1", "2", "0"));
}
public void testOrder5() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 2."),
runMain("1", "0", "2"));
}
public void testOrder6WithATie() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 1."),
runMain("0", "1", "1"));
}
public void testOrder7WithATie() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 1."),
runMain("1", "0", "1"));
}
public void testOrder8WithATie() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 1."),
runMain("1", "1", "0"));
}
public void testAllTied() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is 0."),
runMain("0", "0", "0"));
}
public void testNegatives() {
assertEquals(
assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The maximum is -1."),
runMain("-1", "-2", "-3"));
}
}
......@@ -34,97 +34,121 @@ public class TrainTest extends TestCase {
return collector.toString();
}
public void testCaseZero() {
public void testStoppedTrainWithNoRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("0.0", "no", "no"));
}
public void testCaseOne() {
public void testStoppedTrainWithClosedTrackProtection() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("0.0", "no", "yes"));
}
public void testCaseTwo() {
public void testStoppedTrainWithSpeedReduction() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("0.0", "yes", "no"));
}
public void testCaseThree() {
public void testStoppedTrainWithBothRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("0.0", "yes", "yes"));
}
public void testCaseFour() {
public void testSlowTrainWithNoRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("18.0", "no", "no"));
}
public void testCaseFive() {
public void testSlowTrainWithClosedTrackProtection() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("18.0", "no", "yes"));
}
public void testCaseSix() {
public void testSlowTrainWithSpeedReduction() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("18.0", "yes", "no"));
}
public void testCaseSeven() {
public void testSlowTrainWithBothRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("18.0", "yes", "yes"));
}
public void testCaseEight() {
public void testAlmostSlowTrainWithNoRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("18.1", "no", "no"));
}
public void testCaseNine() {
public void testAlmostSlowTrainWithClosedTrackProtection() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("18.1", "no", "yes"));
}
public void testCaseTen() {
public void testAlmostSlowTrainWithSpeedReduction() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("18.1", "yes", "no"));
}
public void testCaseEleven() {
public void testAlmostSlowTrainWithBothRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("18.1", "yes", "yes"));
}
public void testCaseTwelve() {
public void testAlmostFastTrainWithNoRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Safe"), runMain("56.0", "no", "no"));
}
public void testAlmostFastTrainWithClosedTrackProtection() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.0", "no", "yes"));
}
public void testAlmostFastTrainWithSpeedReduction() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.0", "yes", "no"));
}
public void testAlmostFastTrainWithBothRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.0", "yes", "yes"));
}
public void testFastTrainWithNoRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.1", "no", "no"));
}
public void testCaseThirteen() {
public void testFastTrainWithClosedTrackProtection() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.1", "no", "yes"));
}
public void testCaseFourteen() {
public void testFastTrainWithSpeedReduction() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.1", "yes", "no"));
}
public void testCaseFifteen() {
public void testFastTrainWithBothRestrictions() {
assertEquals(assemble("What is the train's speed (in km/h)? "
+ "Is there a temporary speed reduction (yes/no)? " + "Is closed-track protection active (yes/no)? "
+ "Unsafe"), runMain("56.1", "yes", "yes"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment