mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
38 lines
591 B
Go
38 lines
591 B
Go
package function
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/duke-git/lancet/internal"
|
|
)
|
|
|
|
func TestWatcher(t *testing.T) {
|
|
assert := internal.NewAssert(t, "TestWatcher")
|
|
|
|
w := &Watcher{}
|
|
w.Start()
|
|
|
|
longRunningTask()
|
|
|
|
assert.Equal(true, w.excuting)
|
|
|
|
w.Stop()
|
|
|
|
eapsedTime := w.GetElapsedTime().Milliseconds()
|
|
t.Log("Elapsed Time (milsecond)", eapsedTime)
|
|
|
|
assert.Equal(false, w.excuting)
|
|
|
|
w.Reset()
|
|
|
|
assert.Equal(int64(0), w.startTime)
|
|
assert.Equal(int64(0), w.stopTime)
|
|
}
|
|
|
|
func longRunningTask() {
|
|
var slice []int64
|
|
for i := 0; i < 10000000; i++ {
|
|
slice = append(slice, int64(i))
|
|
}
|
|
}
|