1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00
json-iterator/extra/time_as_int64_codec_test.go
2017-06-20 17:46:29 +08:00

25 lines
582 B
Go

package extra
import (
"testing"
"time"
"github.com/json-iterator/go/require"
"github.com/json-iterator/go"
)
func Test_time_as_int64(t *testing.T) {
should := require.New(t)
RegisterTimeAsInt64Codec(time.Nanosecond)
output, err := jsoniter.Marshal(time.Unix(1, 1002))
should.Nil(err)
should.Equal("1000001002", string(output))
}
func Test_time_as_int64_keep_microsecond(t *testing.T) {
should := require.New(t)
RegisterTimeAsInt64Codec(time.Microsecond)
output, err := jsoniter.Marshal(time.Unix(1, 1002))
should.Nil(err)
should.Equal("1000001", string(output))
}