Esempio n. 1
0
  @Test
  public void testDrive() {
    Car testCar = new Car(50);
    testCar.addGas(20);
    testCar.drive(25);
    double gallons = testCar.getGasInTank();
    assertEquals(19.5, gallons, 1e-6);

    testCar.drive(100);
    gallons = testCar.getGasInTank();
    assertEquals(17.5, gallons, 1e-6);
  }
Esempio n. 2
0
  @Test
  public void test() {
    Car car = new Car(50);

    car.addGas(20); // Tank 20 gallons
    car.drive(100); // Drive 100 miles
    double gasLeft = car.getGasInTank(); // Get gas remaining in tank

    // expected 18
    assertEquals(18, gasLeft, 0);
  }