diff --git a/marshal_test.go b/marshal_test.go index 59a5211dc..e021617e4 100644 --- a/marshal_test.go +++ b/marshal_test.go @@ -6,15 +6,13 @@ package gocql import ( "bytes" "encoding/binary" + "gopkg.in/inf.v0" "math" "math/big" "net" "reflect" "strings" "testing" - "time" - - "gopkg.in/inf.v0" ) type AliasInt int @@ -122,27 +120,6 @@ var marshalTests = []struct { nil, nil, }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89\xa2\xc3\xc2\x9a\xe0F\x91\x06"), - Duration{Months: 1233, Days: 123213, Nanoseconds: 2312323}, - nil, - nil, - }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89\xa1\xc3\xc2\x99\xe0F\x91\x05"), - Duration{Months: -1233, Days: -123213, Nanoseconds: -2312323}, - nil, - nil, - }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x02\x04\x80\xe6"), - Duration{Months: 1, Days: 2, Nanoseconds: 115}, - nil, - nil, - }, { CollectionType{ NativeType: NativeType{proto: 2, typ: TypeList}, @@ -546,36 +523,6 @@ var unmarshalTests = []struct { map[string]int{"foo": 1}, unmarshalErrorf("unmarshal map: unexpected eof"), }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89\xa2\xc3\xc2\x9a\xe0F\x91"), - Duration{}, - unmarshalErrorf("failed to unmarshal duration into *gocql.Duration: failed to extract nanoseconds: data expect to have 9 bytes, but it has only 8"), - }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89\xa2\xc3\xc2\x9a"), - Duration{}, - unmarshalErrorf("failed to unmarshal duration into *gocql.Duration: failed to extract nanoseconds: unexpected eof"), - }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89\xa2\xc3\xc2"), - Duration{}, - unmarshalErrorf("failed to unmarshal duration into *gocql.Duration: failed to extract days: data expect to have 5 bytes, but it has only 4"), - }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89\xa2"), - Duration{}, - unmarshalErrorf("failed to unmarshal duration into *gocql.Duration: failed to extract days: unexpected eof"), - }, - { - NativeType{proto: 5, typ: TypeDuration}, - []byte("\x89"), - Duration{}, - unmarshalErrorf("failed to unmarshal duration into *gocql.Duration: failed to extract month: data expect to have 2 bytes, but it has only 1"), - }, } func decimalize(s string) *inf.Dec { @@ -1234,51 +1181,6 @@ func BenchmarkUnmarshalVarchar(b *testing.B) { } } -func TestMarshalDuration(t *testing.T) { - durationS := "1h10m10s" - duration, _ := time.ParseDuration(durationS) - expectedData := append([]byte{0, 0}, encVint(duration.Nanoseconds())...) - var marshalDurationTests = []struct { - Info TypeInfo - Data []byte - Value interface{} - }{ - { - NativeType{proto: 5, typ: TypeDuration}, - expectedData, - duration.Nanoseconds(), - }, - { - NativeType{proto: 5, typ: TypeDuration}, - expectedData, - duration, - }, - { - NativeType{proto: 5, typ: TypeDuration}, - expectedData, - durationS, - }, - { - NativeType{proto: 5, typ: TypeDuration}, - expectedData, - &duration, - }, - } - - for i, test := range marshalDurationTests { - t.Log(i, test) - data, err := Marshal(test.Info, test.Value) - if err != nil { - t.Errorf("marshalTest[%d]: %v", i, err) - continue - } - if !bytes.Equal(data, test.Data) { - t.Errorf("marshalTest[%d]: expected %x (%v), got %x (%v) for time %s", i, - test.Data, decInt(test.Data), data, decInt(data), test.Value) - } - } -} - func TestReadCollectionSize(t *testing.T) { listV2 := CollectionType{ NativeType: NativeType{proto: 2, typ: TypeList}, diff --git a/tests/serialization/marshal_18_duration_corrupt_test.go b/tests/serialization/marshal_18_duration_corrupt_test.go index b8d8a360c..254a417dc 100644 --- a/tests/serialization/marshal_18_duration_corrupt_test.go +++ b/tests/serialization/marshal_18_duration_corrupt_test.go @@ -20,9 +20,6 @@ func TestMarshalDurationCorrupt(t *testing.T) { return gocql.Unmarshal(tType, bytes, i) } - // unmarshal `gocql.Duration` with data which more cql values (int32,int32,int64) size does not return an error - brokenDuration := serialization.GetTypes(gocql.Duration{}, &gocql.Duration{}) - serialization.NegativeMarshalSet{ Values: mod.Values{ "23123113", "sda", @@ -34,7 +31,6 @@ func TestMarshalDurationCorrupt(t *testing.T) { Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_month1", t, unmarshal) serialization.NegativeUnmarshalSet{ @@ -42,7 +38,6 @@ func TestMarshalDurationCorrupt(t *testing.T) { Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_month2", t, unmarshal) serialization.NegativeUnmarshalSet{ @@ -50,7 +45,6 @@ func TestMarshalDurationCorrupt(t *testing.T) { Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_day1", t, unmarshal) serialization.NegativeUnmarshalSet{ @@ -58,31 +52,41 @@ func TestMarshalDurationCorrupt(t *testing.T) { Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_day2", t, unmarshal) serialization.NegativeUnmarshalSet{ - Data: []byte("\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe"), + Data: []byte("\x00\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff"), Values: mod.Values{ - int64(0), time.Duration(0), "", gocql.Duration{}, + int64(0), time.Duration(0), "", }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_nano1", t, unmarshal) serialization.NegativeUnmarshalSet{ - Data: []byte("\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff"), + Data: []byte("\x01\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff"), Values: mod.Values{ - int64(0), time.Duration(0), "", gocql.Duration{}, + int64(0), time.Duration(0), "", }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_nano2", t, unmarshal) + serialization.NegativeUnmarshalSet{ + Data: []byte("\x01\x00\x41\xfd\xfc\x9b\xc5\xc4\x9e\x00\x00"), + Values: mod.Values{ + int64(0), time.Duration(0), "", + }.AddVariants(mod.All...), + }.Run("big_data_nano3", t, unmarshal) + + serialization.NegativeUnmarshalSet{ + Data: []byte("\x00\xc3\x41\xfd\xfc\x9b\xc5\xc4\x9e\x00\x01"), + Values: mod.Values{ + int64(0), time.Duration(0), "", + }.AddVariants(mod.All...), + }.Run("big_data_nano4", t, unmarshal) + serialization.NegativeUnmarshalSet{ Data: []byte("\x00\x00\x00\x00"), Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_len1", t, unmarshal) serialization.NegativeUnmarshalSet{ @@ -90,7 +94,6 @@ func TestMarshalDurationCorrupt(t *testing.T) { Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_len2", t, unmarshal) serialization.NegativeUnmarshalSet{ @@ -98,7 +101,6 @@ func TestMarshalDurationCorrupt(t *testing.T) { Values: mod.Values{ int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenTypes: brokenDuration, }.Run("big_data_len3", t, unmarshal) serialization.NegativeUnmarshalSet{ @@ -108,6 +110,13 @@ func TestMarshalDurationCorrupt(t *testing.T) { }.AddVariants(mod.All...), }.Run("small_data_len1", t, unmarshal) + serialization.NegativeUnmarshalSet{ + Data: []byte("\x00"), + Values: mod.Values{ + int64(0), time.Duration(0), "", gocql.Duration{}, + }.AddVariants(mod.All...), + }.Run("small_data_len2", t, unmarshal) + serialization.NegativeUnmarshalSet{ Data: []byte("\xf0\xff\xff\xff\xfe\x00"), Values: mod.Values{ @@ -121,4 +130,25 @@ func TestMarshalDurationCorrupt(t *testing.T) { int64(0), time.Duration(0), "", gocql.Duration{}, }.AddVariants(mod.All...), }.Run("small_data_len3", t, unmarshal) + + serialization.NegativeUnmarshalSet{ + Data: []byte("\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff"), + Values: mod.Values{ + int64(0), time.Duration(0), "", gocql.Duration{}, + }.AddVariants(mod.All...), + }.Run("small_data_len_nanos", t, unmarshal) + + serialization.NegativeUnmarshalSet{ + Data: []byte("\x00\xf0\xff\xff\xff\x00"), + Values: mod.Values{ + int64(0), time.Duration(0), "", gocql.Duration{}, + }.AddVariants(mod.All...), + }.Run("small_data_len_days", t, unmarshal) + + serialization.NegativeUnmarshalSet{ + Data: []byte("\xf0\xff\xff\xff\x00\x00"), + Values: mod.Values{ + int64(0), time.Duration(0), "", gocql.Duration{}, + }.AddVariants(mod.All...), + }.Run("small_data_len_months", t, unmarshal) } diff --git a/tests/serialization/marshal_18_duration_test.go b/tests/serialization/marshal_18_duration_test.go index c46be7594..fea8ae87c 100644 --- a/tests/serialization/marshal_18_duration_test.go +++ b/tests/serialization/marshal_18_duration_test.go @@ -16,19 +16,15 @@ import ( func TestMarshalsDuration(t *testing.T) { tType := gocql.NewNativeType(4, gocql.TypeDuration, "") - marshal := func(i interface{}) ([]byte, error) { return gocql.Marshal(tType, i) } - unmarshal := func(bytes []byte, i interface{}) error { - return gocql.Unmarshal(tType, bytes, i) - } - - unmarshalUnsupported := serialization.GetTypes(mod.Values{int64(0), time.Duration(0), ""}.AddVariants(mod.All...)...) + const nanoDay = 24 * 60 * 60 * 1000 * 1000 * 1000 - brokenCustom := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) + marshal := func(i interface{}) ([]byte, error) { return gocql.Marshal(tType, i) } + unmarshal := func(bytes []byte, i interface{}) error { return gocql.Unmarshal(tType, bytes, i) } serialization.PositiveSet{ Data: nil, Values: mod.Values{ - (*int64)(nil), (*time.Duration)(nil), (*string)(nil), (*gocql.Duration)(nil), + (*int64)(nil), (*time.Duration)(nil), (*string)(nil), "", (*gocql.Duration)(nil), }.AddVariants(mod.CustomType), BrokenUnmarshalTypes: serialization.GetTypes(int64(0)), }.Run("[nil]nullable", t, marshal, unmarshal) @@ -36,26 +32,22 @@ func TestMarshalsDuration(t *testing.T) { serialization.PositiveSet{ Data: nil, Values: mod.Values{ - int64(0), time.Duration(0), "", gocql.Duration{}, + int64(0), time.Duration(0), gocql.Duration{}, }.AddVariants(mod.CustomType), - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("[nil]unmarshal", t, nil, unmarshal) serialization.PositiveSet{ Data: make([]byte, 0), Values: mod.Values{ - int64(0), time.Duration(0), "0", gocql.Duration{}, + int64(0), time.Duration(0), "0s", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("[]unmarshal", t, nil, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\x00"), Values: mod.Values{ - int64(0), time.Duration(0), "0", gocql.Duration{}, + int64(0), time.Duration(0), "0s", gocql.Duration{}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("zeros", t, marshal, unmarshal) // sets for months @@ -64,8 +56,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 1, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("months1", t, marshal, unmarshal) serialization.PositiveSet{ @@ -73,8 +63,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: -1, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("months-1", t, marshal, unmarshal) serialization.PositiveSet{ @@ -82,8 +70,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MaxInt8, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMaxInt8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -91,8 +77,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MinInt8, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMinInt8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -100,8 +84,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MaxUint8, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMaxUint8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -109,8 +91,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: -math.MaxUint8, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMinUint8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -118,8 +98,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MaxInt16, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMaxInt16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -127,8 +105,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MinInt16, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMinInt16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -136,8 +112,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MaxUint16, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMaxUint16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -145,8 +119,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: -math.MaxUint16, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMinUint16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -154,8 +126,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MaxInt32, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMaxInt32", t, marshal, unmarshal) serialization.PositiveSet{ @@ -163,8 +133,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: math.MinInt32, Days: 0, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("monthsMinInt32", t, marshal, unmarshal) // sets for days @@ -173,8 +141,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: 1, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("days1", t, marshal, unmarshal) serialization.PositiveSet{ @@ -182,8 +148,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: -1, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("days-1", t, marshal, unmarshal) serialization.PositiveSet{ @@ -191,8 +155,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MaxInt8, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMaxInt8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -200,8 +162,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MinInt8, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMinInt8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -209,8 +169,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MaxUint8, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMaxUint8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -218,8 +176,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: -math.MaxUint8, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMinUint8", t, marshal, unmarshal) serialization.PositiveSet{ @@ -227,8 +183,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MaxInt16, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMaxInt16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -236,8 +190,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MinInt16, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMinInt16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -245,8 +197,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MaxUint16, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMaxUint16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -254,8 +204,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: -math.MaxUint16, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMinUint16", t, marshal, unmarshal) serialization.PositiveSet{ @@ -263,8 +211,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MaxInt32, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMaxInt32", t, marshal, unmarshal) serialization.PositiveSet{ @@ -272,149 +218,117 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Months: 0, Days: math.MinInt32, Nanoseconds: 0}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("daysMinInt32", t, marshal, unmarshal) //sets for nanoseconds serialization.PositiveSet{ Data: []byte("\x00\x00\x02"), Values: mod.Values{ - int64(1), time.Duration(1), "1ns", + int64(1), time.Duration(1), time.Duration(1).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: 1}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanos1", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\x01"), Values: mod.Values{ - int64(-1), time.Duration(-1), "-1ns", + int64(-1), time.Duration(-1), time.Duration(-1).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: -1}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanos-1", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\x80\xfe"), Values: mod.Values{ - int64(math.MaxInt8), time.Duration(math.MaxInt8), "127ns", + int64(math.MaxInt8), time.Duration(math.MaxInt8), time.Duration(math.MaxInt8).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MaxInt8}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMaxInt8", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\x80\xff"), Values: mod.Values{ - int64(math.MinInt8), time.Duration(math.MinInt8), "-128ns", + int64(math.MinInt8), time.Duration(math.MinInt8), time.Duration(math.MinInt8).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MinInt8}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMinInt8", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\x81\xfe"), Values: mod.Values{ - int64(math.MaxUint8), time.Duration(math.MaxUint8), "255ns", + int64(math.MaxUint8), time.Duration(math.MaxUint8), time.Duration(math.MaxUint8).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MaxUint8}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMaxUint8", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\x81\xfd"), Values: mod.Values{ - -int64(math.MaxUint8), -time.Duration(math.MaxUint8), "-255ns", + int64(-math.MaxUint8), time.Duration(-math.MaxUint8), time.Duration(-math.MaxUint8).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: -math.MaxUint8}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMinUint8", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xc0\xff\xfe"), Values: mod.Values{ - int64(math.MaxInt16), time.Duration(math.MaxInt16), "32767ns", + int64(math.MaxInt16), time.Duration(math.MaxInt16), time.Duration(math.MaxInt16).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MaxInt16}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMaxInt16", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xc0\xff\xff"), Values: mod.Values{ - int64(math.MinInt16), time.Duration(math.MinInt16), "-32768ns", + int64(math.MinInt16), time.Duration(math.MinInt16), time.Duration(math.MinInt16).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MinInt16}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMinInt16", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xc1\xff\xfe"), Values: mod.Values{ - int64(math.MaxUint16), time.Duration(math.MaxUint16), "65535ns", + int64(math.MaxUint16), time.Duration(math.MaxUint16), time.Duration(math.MaxUint16).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MaxUint16}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMaxUint16", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xc1\xff\xfd"), Values: mod.Values{ - -int64(math.MaxUint16), -time.Duration(math.MaxUint16), "-65535ns", + int64(-math.MaxUint16), time.Duration(-math.MaxUint16), time.Duration(-math.MaxUint16).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: -math.MaxUint16}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMinUint16", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xf0\xff\xff\xff\xfe"), Values: mod.Values{ - int64(math.MaxInt32), time.Duration(math.MaxInt32), "2147483647ns", + int64(math.MaxInt32), time.Duration(math.MaxInt32), time.Duration(math.MaxInt32).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MaxInt32}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMaxInt32", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xf0\xff\xff\xff\xff"), Values: mod.Values{ - int64(math.MinInt32), time.Duration(math.MinInt32), "-2147483648ns", + int64(math.MinInt32), time.Duration(math.MinInt32), time.Duration(math.MinInt32).String(), gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MinInt32}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMinInt32", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe"), Values: mod.Values{ - int64(math.MaxInt64), time.Duration(math.MaxInt64), "9223372036854775807ns", gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MaxInt64}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMaxInt64", t, marshal, unmarshal) serialization.PositiveSet{ Data: []byte("\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff"), Values: mod.Values{ - int64(math.MinInt64), time.Duration(math.MinInt64), "-9223372036854775808ns", gocql.Duration{Months: 0, Days: 0, Nanoseconds: math.MinInt64}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("nanosMinInt64", t, marshal, unmarshal) // sets for full range @@ -423,8 +337,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Days: 1, Months: 1, Nanoseconds: 1}, }.AddVariants(mod.All...), - BrokenMarshalTypes: brokenCustom, - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("111", t, marshal, unmarshal) serialization.PositiveSet{ @@ -432,7 +344,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Days: -1, Months: -1, Nanoseconds: -1}, }.AddVariants(mod.All...), - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("-111", t, marshal, unmarshal) serialization.PositiveSet{ @@ -440,7 +351,6 @@ func TestMarshalsDuration(t *testing.T) { Values: mod.Values{ gocql.Duration{Days: math.MaxInt32, Months: math.MaxInt32, Nanoseconds: math.MaxInt64}, }.AddVariants(mod.All...), - BrokenUnmarshalTypes: unmarshalUnsupported, }.Run("max", t, marshal, unmarshal) serialization.PositiveSet{