/** testing for method getStepsTaken */ @Test public void testGetStepsTaken() { Simulator s = new Simulator(numCustomsDesks, numPassengers); assertEquals(0, s.getStepsTaken()); s.step(); assertEquals(1, s.getStepsTaken()); }
/** testing for method passengerClearedCustoms */ @Test public void testPassengerClearedCustoms() { Simulator s = new Simulator(numCustomsDesks, numPassengers); assertFalse(s.passengerClearedCustoms()); s.step(); assertFalse(s.passengerClearedCustoms()); s.step(); assertTrue(s.passengerClearedCustoms()); }
/** testing for method moreSteps */ @Test public void testMoreSteps() { Simulator s = new Simulator(numCustomsDesks, numPassengers); assertTrue(s.moreSteps()); s.step(); assertTrue(s.moreSteps()); s.step(); assertFalse(s.moreSteps()); }
/** testing for method getCurrentIndex */ @Test public void testGetCurrentIndex() { Simulator s = new Simulator(numCustomsDesks, numPassengers); assertEquals(-1, s.getCurrentIndex()); s.step(); int a = s.getCurrentIndex(); assertTrue(a < 3 && a >= 0); s.step(); a = s.getCurrentIndex(); assertTrue(a >= 0); }
@Test public void test() { Simulator sim = new Simulator(10, 20); SimObject s1 = new SimObject(1, 2, 2); sim.add(s1); SimObject s2 = new SimObject(10, 10, 2); sim.add(s2); Robot bot = new Robot(5, 10, 0); sim.add(bot); assertTrue(bot.withinSonar(s2)); assertFalse(bot.withinSonar(s1)); assertEquals(5.0, sim.findClosestEdge(), 0.01); bot.turn(Direction.FWD); for (int i = 0; i < 8; i++) bot.update(); assertEquals(10.0, sim.findClosestEdge(), 0.01); for (int i = 0; i < 8; i++) bot.update(); assertEquals(5.0, sim.findClosestEdge(), 0.01); for (int i = 0; i < 8; i++) bot.update(); assertEquals(10.0, sim.findClosestEdge(), 0.01); }
/** testing for method averageWaitTime */ @Test public void testAverageWaitTime() { Simulator s = new Simulator(numCustomsDesks, numPassengers); assertEquals(0, s.averageWaitTime(), .001); }
/** testing for method numberOfSteps */ @Test public void testTotalNumberOfSteps() { Simulator s = new Simulator(numCustomsDesks, numPassengers); assertEquals(2, s.totalNumberOfSteps()); }