1
0
Fork 0
go packages which are fine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
mediocre-go-lib/mtime/dur_test.go

30 lines
560 B

package mtime
import (
. "testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestDuration(t *T) {
{
b, err := Duration{5 * time.Second}.MarshalText()
assert.NoError(t, err)
assert.Equal(t, []byte("5s"), b)
var d Duration
assert.NoError(t, d.UnmarshalText(b))
assert.Equal(t, 5*time.Second, d.Duration)
}
{
b, err := Duration{5 * time.Second}.MarshalJSON()
assert.NoError(t, err)
assert.Equal(t, []byte(`"5s"`), b)
var d Duration
assert.NoError(t, d.UnmarshalJSON(b))
assert.Equal(t, 5*time.Second, d.Duration)
}
}