github.com/sandwich-go/boost@v1.3.29/xconv/binary_test.go (about) 1 package xconv 2 3 import ( 4 . "github.com/smartystreets/goconvey/convey" 5 "testing" 6 ) 7 8 func TestBinary(t *testing.T) { 9 Convey(`test binary`, t, func() { 10 var buf = []byte{0x00, 0x00, 0x48, 0x42} 11 So(LittleEndianDecodeToFloat32(buf), ShouldEqual, float32(50)) 12 buf = []byte{24, 45, 68, 84, 251, 33, 9, 64} 13 So(LittleEndianDecodeToFloat64(buf), ShouldEqual, 3.141592653589793) 14 buf = []byte{0x48} 15 So(LittleEndianDecodeToInt64(buf), ShouldEqual, 72) 16 So(LittleEndianDecodeToUint64(buf), ShouldEqual, 72) 17 }) 18 }