-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_stopwatch_test.go
58 lines (48 loc) · 1023 Bytes
/
test_stopwatch_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
package stopwatch
import (
"testing"
"time"
"github.com/google/go-cmp/cmp"
)
func TestTestStopwatchGetResults(t *testing.T) {
testStopWatch := NewTestStopWatch()
testStopWatch.Start()
testStopWatch.Step("a")
testStopWatch.Step("b")
testStopWatch.Step("c")
actual := testStopWatch.GetResults()
expect := &Results{
Steps: []Step{
{Label: "a", Duration: time.Millisecond},
{Label: "b", Duration: time.Millisecond},
{Label: "c", Duration: time.Millisecond},
},
}
diff := cmp.Diff(expect, actual)
if diff != "" {
t.Fatal(diff)
}
}
func TestTestStopwatchGetResultMap(t *testing.T) {
testStopWatch := NewTestStopWatch()
testStopWatch.Start()
testStopWatch.Step("a")
testStopWatch.Step("b")
testStopWatch.Step("c")
actual := testStopWatch.GetResultMap()
expect := []map[string]int64{
{
"a": int64(time.Millisecond),
},
{
"b": int64(time.Millisecond),
},
{
"c": int64(time.Millisecond),
},
}
diff := cmp.Diff(expect, actual)
if diff != "" {
t.Fatal(diff)
}
}