-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkindle_test.go
40 lines (35 loc) · 963 Bytes
/
kindle_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
package main
import (
"testing"
"time"
)
func TestNextWakeupToday(t *testing.T) {
now := time.Date(2009, time.November, 5, 5, 0, 0, 0, time.UTC)
want := 3600
got := nextWakeup(now, 6, 0)
if got != want {
t.Fatalf(`nextWakeup() = %v, want match for %#v, nil`, got, want)
}
}
func TestNextWakeupTomorrow(t *testing.T) {
now := time.Date(2009, time.November, 5, 7, 0, 0, 0, time.UTC)
want := 82800
got := nextWakeup(now, 6, 0)
if got != want {
t.Fatalf(`nextWakeup() = %v, want match for %#v, nil`, got, want)
}
}
func TestParseBatteryLevel(t *testing.T) {
want := 30
got, err := parseBatteryLevel("30%")
if got != want && err != nil {
t.Fatalf(`parseBatteryLevel() = %v, %v, want match for %#v, nil`, got, err, want)
}
}
func TestParseBadBatteryLevel(t *testing.T) {
want := -1
got, err := parseBatteryLevel("abc")
if got != want && err != nil {
t.Fatalf(`parseBatteryLevel() = %v, %v, want match for %#v, nil`, got, err, want)
}
}