Skip to content

Commit 5d4483c

Browse files
committed
fix malfunction of stopwatch unit test and reduce testing time
1 parent 86aabbc commit 5d4483c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import (
66
)
77

88
func TestStopWatch(t *testing.T) {
9-
testData := []int{1, 2}
9+
testData := []int{100, 200} //Millisecond
1010
for _, value := range testData {
1111
sw := &StopWatch{}
1212

1313
sw.Start()
14-
time.Sleep(time.Duration(value) * time.Second)
14+
time.Sleep(time.Duration(value) * time.Millisecond)
1515
sw.Stop()
1616

17-
if int64(sw.Elapsed)/1000000 == int64(time.Duration(value)*time.Second) {
18-
t.Errorf("expected %d, get %d", time.Duration(value)*time.Second, sw.Elapsed)
17+
if int64(sw.Elapsed)/1000000 != int64(time.Duration(value)) {
18+
t.Errorf("expected %d, get %d", time.Duration(value)*time.Millisecond, sw.Elapsed)
1919
}
2020
}
2121

0 commit comments

Comments
 (0)