-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduration_test.go
More file actions
47 lines (36 loc) · 909 Bytes
/
duration_test.go
File metadata and controls
47 lines (36 loc) · 909 Bytes
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
package proto
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestDurationNanos(t *testing.T) {
pb := DurationNanos(100)
d := pb.Duration()
assert.Equal(t, time.Duration(100)*time.Nanosecond, d)
}
func TestDurationMillis(t *testing.T) {
pb := DurationMillis(100)
d := pb.Duration()
assert.Equal(t, time.Duration(100)*time.Millisecond, d)
}
func TestDurationSeconds(t *testing.T) {
pb := DurationSeconds(100)
d := pb.Duration()
assert.Equal(t, time.Duration(100)*time.Second, d)
}
func TestDuration_Duration_nil(t *testing.T) {
pb := &Duration{Unit: nil}
d := pb.Duration()
assert.Equal(t, 0*time.Second, d)
}
type unknownDuration struct{}
func (u *unknownDuration) isDuration_Unit() {}
func TestDuration_Duration_unknown(t *testing.T) {
defer func() {
err := recover()
assert.NotNil(t, err)
}()
pb := &Duration{Unit: &unknownDuration{}}
pb.Duration()
}