forked from jacexh/ultron
-
Notifications
You must be signed in to change notification settings - Fork 4
/
timer_test.go
38 lines (33 loc) · 984 Bytes
/
timer_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
package ultron
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestTimerConverterUniformRandomTimer(t *testing.T) {
t1 := &UniformRandomTimer{MinWait: 100 * time.Millisecond, MaxWait: 200 * time.Microsecond}
converter := newTimeConveter()
dto, err := converter.convertTimer(t1)
assert.Nil(t, err)
t2, err := converter.convertDTO(dto)
assert.Nil(t, err)
assert.EqualValues(t, t1, t2)
}
func TestTimerConverterGaussianRandomTimer(t *testing.T) {
t1 := &GaussianRandomTimer{DesiredMean: 100.11, StdDev: 15.3}
converter := newTimeConveter()
dto, err := converter.convertTimer(t1)
assert.Nil(t, err)
t2, err := converter.convertDTO(dto)
assert.Nil(t, err)
assert.EqualValues(t, t1, t2)
}
func TestTimerConverterNonStopTimer(t *testing.T) {
t1 := NonstopTimer{}
converter := newTimeConveter()
dto, err := converter.convertTimer(t1)
assert.Nil(t, err)
t2, err := converter.convertDTO(dto)
assert.Nil(t, err)
assert.EqualValues(t, t1, t2)
}