-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
88 lines (77 loc) · 1.96 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"testing"
"time"
)
func TestDepartureTime(t *testing.T) {
deptime := departureTime("10:30")
expected_time := Time{10, 30}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestDepartureTime2(t *testing.T) {
deptime := departureTime("0:0")
expected_time := Time{0, 0}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestDepartureTime3(t *testing.T) {
deptime := departureTime("00:00")
expected_time := Time{0, 0}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestDepartureTime4(t *testing.T) {
deptime := departureTime("23:59")
expected_time := Time{23, 59}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestDepartureTime5(t *testing.T) {
deptime := departureTime("44:30")
now := time.Now()
expected_time := Time{now.Hour(), now.Minute()}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestDepartureTime6(t *testing.T) {
deptime := departureTime("24:30")
now := time.Now()
expected_time := Time{now.Hour(), now.Minute()}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestDepartureTime7(t *testing.T) {
deptime := departureTime("12:60")
now := time.Now()
expected_time := Time{now.Hour(), now.Minute()}
if deptime != expected_time {
t.Errorf("got %v\nwant %v", deptime, expected_time)
}
}
func TestToString(t *testing.T) {
value := Time{hour: 8, minute: 8}
ret := value.toString()
if ret != "8:08 " {
t.Errorf("got %v, wrong Format", ret)
}
}
func TestToString2(t *testing.T) {
value := Time{10, 10}
ret := value.toString()
if ret != "10:10 " {
t.Errorf("got %v, wrong Format", ret)
}
}
func TestCreateTimetable(t *testing.T) {
timetable := createTimetable()
if len(timetable) == 0 {
t.Error("Timetable is nil. Current URL may be out of date.")
}
}