gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/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  }