コード例 #1
0
  public void testBadConstructorArgs() {
    Time t = new Time("12:01PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 12, t.getHour());
    assertEquals("Bad format: Minute should be set", 1, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time("6:21       PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time("06:21       PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time("6:21       pm   ", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time(" 6 : 21       Pm   ", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());
  }
コード例 #2
0
  public void testAltConstructor() {
    Time t = new Time(0, 0);
    assertEquals("Hour should be set", 0, t.getHour());
    assertEquals("Minute should be set", 0, t.getMinute());
    assertTrue("AM/PM should be set", t.isAM());

    t = new Time(12, 0);
    assertEquals("Hour should be set", 12, t.getHour());
    assertEquals("Minute should be set", 0, t.getMinute());
    assertFalse("AM/PM should be set", t.isAM());
  }
コード例 #3
0
  public void testPMConstructor() {
    Time t = new Time("12:01 PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Hour should be set", 12, t.getHour());
    assertEquals("Minute should be set", 1, t.getMinute());
    assertFalse("AM/PM should be set", t.isAM());

    t = new Time("6:21 PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Hour should be set", 18, t.getHour());
    assertEquals("Minute should be set", 21, t.getMinute());
    assertFalse("AM/PM should be set", t.isAM());
  }
コード例 #4
0
  public void testAMConstructor() {
    Time t = new Time("12:10 AM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Route should be set", "Route T", t.getRoute());
    assertEquals("TimeOfWeek should be set", Time.TimeOfWeek.Weekday, t.getTimeOfWeek());
    assertEquals("Hour should be set", 0, t.getHour());
    assertEquals("Minute should be set", 10, t.getMinute());
    assertTrue("AM/PM should be set", t.isAM());

    t = new Time("1:46 AM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Hour should be set", 1, t.getHour());
    assertEquals("Minute should be set", 46, t.getMinute());
    assertTrue("AM/PM should be set", t.isAM());
  }