From 76dfd8e63405d31f43bc7bf8a16d8a33a97fb6c6 Mon Sep 17 00:00:00 2001 From: Christopher Bohn <bohn@unl.edu> Date: Thu, 3 Oct 2024 10:08:42 -0500 Subject: [PATCH] Reformatted for 2024 formatting convention --- .../unl/cse/soft160/conditionals/Caucus.java | 22 +- .../cse/soft160/conditionals/CaucusTest.java | 156 ++++---- .../soft160/conditionals/SpeedLimitTest.java | 366 +++++++++--------- 3 files changed, 272 insertions(+), 272 deletions(-) diff --git a/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java b/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java index 83a08d0..2329e9e 100644 --- a/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java +++ b/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java @@ -3,15 +3,15 @@ package edu.unl.cse.soft160.conditionals; import java.util.Scanner; public class Caucus { - public static void main(String... arguments) { - Scanner scanner = new Scanner(System.in); - System.out.print("Is today a caucus day (yes/no)? "); - boolean isCaucusDay = scanner.nextLine().matches("[Yy].*"); - System.out.print("Is the precinct report a correctly-formatted electronic report (yes/no)? "); - boolean isCorrectlyFormattedReport = scanner.nextLine().matches("[Yy].*"); - System.out.print("Is the precinct report a telephoned report (yes/no)? "); - boolean isTelephonedReport = scanner.nextLine().matches("[Yy].*"); - // [write code here] - scanner.close(); - } + public static void main(String... arguments) { + Scanner scanner = new Scanner(System.in); + System.out.print("Is today a caucus day (yes/no)? "); + boolean isCaucusDay = scanner.nextLine().matches("[Yy].*"); + System.out.print("Is the precinct report a correctly-formatted electronic report (yes/no)? "); + boolean isCorrectlyFormattedReport = scanner.nextLine().matches("[Yy].*"); + System.out.print("Is the precinct report a telephoned report (yes/no)? "); + boolean isTelephonedReport = scanner.nextLine().matches("[Yy].*"); + // [write code here] + scanner.close(); + } } diff --git a/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java b/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java index 84f32e3..2ec2c0a 100644 --- a/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java +++ b/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java @@ -10,91 +10,91 @@ import java.io.ByteArrayOutputStream; import static org.junit.Assert.*; public class CaucusTest { - protected static String assemble(String... lines) { - return String.join("\n", lines) + "\n"; - } + 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)); - Caucus.main(); - System.setIn(in); - System.setOut(out); - return collector.toString(); - } + 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)); + Caucus.main(); + System.setIn(in); + System.setOut(out); + return collector.toString(); + } - @Test - public void testInvalidReportNotOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), - runMain("no", "no", "no")); - } + @Test + public void testInvalidReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "no", "no")); + } - @Test - public void testTelephoneReportNotOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), - runMain("no", "no", "yes")); - } + @Test + public void testTelephoneReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "no", "yes")); + } - @Test - public void testWellFormattedElectronicReportNotOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), - runMain("no", "yes", "no")); - } + @Test + public void testWellFormattedElectronicReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "yes", "no")); + } - @Test - public void testDuplicatedReportNotOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), - runMain("no", "yes", "yes")); - } + @Test + public void testDuplicatedReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "yes", "yes")); + } - @Test - public void testInvalidReportOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), - runMain("yes", "no", "no")); - } + @Test + public void testInvalidReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("yes", "no", "no")); + } - @Test - public void testTelephoneReportOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), - runMain("yes", "no", "yes")); - } + @Test + public void testTelephoneReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), + runMain("yes", "no", "yes")); + } - @Test - public void testWellFormattedElectronicReportOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), - runMain("yes", "yes", "no")); - } + @Test + public void testWellFormattedElectronicReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), + runMain("yes", "yes", "no")); + } - @Test - public void testDuplicatedReportOnCaucusDay() { - assertEquals( - assemble("Is today a caucus day (yes/no)? " - + "Is the precinct report a correctly-formatted electronic report (yes/no)? " - + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), - runMain("yes", "yes", "yes")); - } + @Test + public void testDuplicatedReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), + runMain("yes", "yes", "yes")); + } } diff --git a/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java b/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java index f0c89cf..f4875f4 100644 --- a/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java +++ b/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java @@ -10,187 +10,187 @@ import java.io.PrintStream; import static org.junit.Assert.*; public class SpeedLimitTest { - 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)); - SpeedLimit.main(); - System.setIn(in); - System.setOut(out); - return collector.toString(); - } - - @Test - public void testStoppedOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "yes", "no")); - } - - @Test - public void testStoppedOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "no", "no")); - } - - @Test - public void testStoppedInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "yes", "yes")); - } - - @Test - public void testStoppedInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "no", "yes")); - } - - @Test - public void testSlowOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "yes", "no")); - } - - @Test - public void testSlowOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "no", "no")); - } - - @Test - public void testSlowInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "yes", "yes")); - } - - @Test - public void testSlowInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "no", "yes")); - } - - @Test - public void testAlmostSlowOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.1", "yes", "no")); - } - - @Test - public void testAlmostSlowOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.1", "no", "no")); - } - - @Test - public void testAlmostSlowInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("25.1", "no", "yes")); - } - - @Test - public void testAlmostSlowInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("25.1", "no", "yes")); - } - - @Test - public void testModerateOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.0", "yes", "no")); - } - - @Test - public void testModerateOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.0", "no", "no")); - } - - @Test - public void testModerateInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.0", "yes", "yes")); - } - - @Test - public void testModerateInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.0", "no", "yes")); - } - - @Test - public void testAlmostModerateOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "yes", "no")); - } - - @Test - public void testAlmostModerateOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.1", "no", "no")); - } - - @Test - public void testAlmostModerateInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "yes", "yes")); - } - - @Test - public void testAlmostModerateInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "no", "yes")); - } - - @Test - public void testFastOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "yes", "no")); - } - - @Test - public void testFastOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("70.0", "no", "no")); - } - - @Test - public void testFastInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "yes", "yes")); - } - - @Test - public void testFastInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "no", "yes")); - } - - @Test - public void testVertFastOnResidentialStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "yes", "no")); - } - - @Test - public void testVertFastOnOtherStreet() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "no", "no")); - } - - @Test - public void testVertFastInResidentialSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "yes", "yes")); - } - - @Test - public void testVertFastInOtherSchoolZone() { - assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " - + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "no", "yes")); - } + 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)); + SpeedLimit.main(); + System.setIn(in); + System.setOut(out); + return collector.toString(); + } + + @Test + public void testStoppedOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "yes", "no")); + } + + @Test + public void testStoppedOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "no", "no")); + } + + @Test + public void testStoppedInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "yes", "yes")); + } + + @Test + public void testStoppedInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "no", "yes")); + } + + @Test + public void testSlowOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "yes", "no")); + } + + @Test + public void testSlowOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "no", "no")); + } + + @Test + public void testSlowInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "yes", "yes")); + } + + @Test + public void testSlowInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "no", "yes")); + } + + @Test + public void testAlmostSlowOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.1", "yes", "no")); + } + + @Test + public void testAlmostSlowOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.1", "no", "no")); + } + + @Test + public void testAlmostSlowInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("25.1", "no", "yes")); + } + + @Test + public void testAlmostSlowInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("25.1", "no", "yes")); + } + + @Test + public void testModerateOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.0", "yes", "no")); + } + + @Test + public void testModerateOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.0", "no", "no")); + } + + @Test + public void testModerateInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.0", "yes", "yes")); + } + + @Test + public void testModerateInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.0", "no", "yes")); + } + + @Test + public void testAlmostModerateOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "yes", "no")); + } + + @Test + public void testAlmostModerateOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.1", "no", "no")); + } + + @Test + public void testAlmostModerateInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "yes", "yes")); + } + + @Test + public void testAlmostModerateInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "no", "yes")); + } + + @Test + public void testFastOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "yes", "no")); + } + + @Test + public void testFastOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("70.0", "no", "no")); + } + + @Test + public void testFastInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "yes", "yes")); + } + + @Test + public void testFastInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "no", "yes")); + } + + @Test + public void testVertFastOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "yes", "no")); + } + + @Test + public void testVertFastOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "no", "no")); + } + + @Test + public void testVertFastInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "yes", "yes")); + } + + @Test + public void testVertFastInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "no", "yes")); + } } -- GitLab