github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-grpc-middleware/logging/zap/options_test.go (about)

     1  package grpc_zap
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"go.uber.org/zap/zapcore"
     6  	"math"
     7  	"testing"
     8  	"time"
     9  )
    10  
    11  func TestDurationToTimeMillisField(t *testing.T) {
    12  	val := DurationToTimeMillisField(time.Microsecond * 100)
    13  	assert.Equal(t, val.Type, zapcore.Float32Type, "should be a float type")
    14  	assert.Equal(t, math.Float32frombits(uint32(val.Integer)), float32(0.1), "sub millisecond values should be correct")
    15  }