01: package org.columba.calendar.ui.comp;
02:
03: import junit.framework.TestCase;
04:
05: public class TimePickerTest extends TestCase {
06:
07: public void testValidateInput() {
08: // valid inputs
09: String value = "11:20";
10: assertEquals(value, TimePicker.validateInput(value));
11: value = "23:59";
12: assertEquals(value, TimePicker.validateInput(value));
13: value = "00:00";
14: assertEquals(value, TimePicker.validateInput(value));
15: value = "10:09";
16: assertEquals(value, TimePicker.validateInput(value));
17: value = "20:50";
18: assertEquals(value, TimePicker.validateInput(value));
19:
20: // recoverable inputs
21: value = "00:000";
22: assertEquals("00:00", TimePicker.validateInput(value));
23: value = "23:000";
24: assertEquals("23:00", TimePicker.validateInput(value));
25: value = "2:000";
26: assertEquals("02:00", TimePicker.validateInput(value));
27: value = "000:0";
28: assertEquals("00:00", TimePicker.validateInput(value));
29: value = "2";
30: assertEquals("02:00", TimePicker.validateInput(value));
31: value = "11";
32: assertEquals("11:00", TimePicker.validateInput(value));
33: value = "23";
34: assertEquals("23:00", TimePicker.validateInput(value));
35: value = "0:1";
36: assertEquals("00:01", TimePicker.validateInput(value));
37: value = "0:9";
38: assertEquals("00:09", TimePicker.validateInput(value));
39: value = "14:9";
40: assertEquals("14:09", TimePicker.validateInput(value));
41:
42: // unrecoverable inputs
43: value = "235:9";
44: assertEquals("00:00", TimePicker.validateInput(value));
45: value = "asdasdl_jk";
46: assertEquals("00:00", TimePicker.validateInput(value));
47: value = "123";
48: assertEquals("00:00", TimePicker.validateInput(value));
49: value = "-3:2";
50: assertEquals("00:00", TimePicker.validateInput(value));
51: value = "-3";
52: assertEquals("00:00", TimePicker.validateInput(value));
53: }
54:
55: }
|