forked from jdefrancesco/GoChessClock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
41 lines (34 loc) · 1.04 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
package main
import "testing"
import "log"
// Sloppy test for toggling, lulz
func TestToggleActive(t *testing.T) {
clk := &ChessClock{whiteTime: 100, blackTime:100, active:White}
log.Printf("currently... %+v", clk)
clk.toggleActive()
if clk.active != Black {
t.Error(
"Current active value", clk.active,
"Expected", Black)
}
log.Printf("After toggle: %+v", clk)
// toggle back
clk.toggleActive()
if clk.active != White {
t.Error("clock.active is ", clk.active, "Should be set to White")
}
log.Printf("Final toggle is: %+v", clk)
}
func TestDisplayTimeMinutes(t *testing.T) {
var secInput ClockTime = 180
// Not a great test but hey...
minsOut, secsOut := secToMins(secInput)
if minsOut != 3 || secsOut != 0 {
t.Errorf("minsOut = %d and secsOut = %d", minsOut, secsOut)
}
secInput = 71
minsOut, secsOut = secToMins(secInput)
if minsOut != 1 || secsOut != 11 {
t.Errorf("minsOut = %d and secsOut = %d", minsOut, secsOut)
}
}