diff --git a/marshal/tests/mod/all.go b/internal/tests/serialization/mod/all.go similarity index 100% rename from marshal/tests/mod/all.go rename to internal/tests/serialization/mod/all.go diff --git a/marshal/tests/mod/custom.go b/internal/tests/serialization/mod/custom.go similarity index 100% rename from marshal/tests/mod/custom.go rename to internal/tests/serialization/mod/custom.go diff --git a/marshal/tests/mod/custom_refs.go b/internal/tests/serialization/mod/custom_refs.go similarity index 100% rename from marshal/tests/mod/custom_refs.go rename to internal/tests/serialization/mod/custom_refs.go diff --git a/marshal/tests/mod/refs.go b/internal/tests/serialization/mod/refs.go similarity index 100% rename from marshal/tests/mod/refs.go rename to internal/tests/serialization/mod/refs.go diff --git a/marshal/tests/serialization/pointers.go b/internal/tests/serialization/pointers.go similarity index 81% rename from marshal/tests/serialization/pointers.go rename to internal/tests/serialization/pointers.go index dc4f69ea4..d6a72ac41 100644 --- a/marshal/tests/serialization/pointers.go +++ b/internal/tests/serialization/pointers.go @@ -5,15 +5,15 @@ import ( "reflect" ) -// ErrFirstPtrChanged this error indicates that a double or single reference was passed to the Unmarshal function +// errFirstPtrChanged this error indicates that a double or single reference was passed to the Unmarshal function // (example (**int)(**0) or (*int)(*0)) and Unmarshal overwritten first reference. -var ErrFirstPtrChanged = errors.New("unmarshal function rewrote first pointer") +var errFirstPtrChanged = errors.New("unmarshal function rewrote first pointer") -// ErrSecondPtrNotChanged this error indicates that a double reference was passed to the Unmarshal function +// errSecondPtrNotChanged this error indicates that a double reference was passed to the Unmarshal function // (example (**int)(**0)) and the function did not overwrite the second reference. // Of course, it's not friendly to the garbage collector, overwriting references to values all the time, // but this is the current implementation `gocql` and changing it can lead to unexpected results in some cases. -var ErrSecondPtrNotChanged = errors.New("unmarshal function did not rewrite second pointer") +var errSecondPtrNotChanged = errors.New("unmarshal function did not rewrite second pointer") func getPointers(i interface{}) *pointer { rv := reflect.ValueOf(i) @@ -45,10 +45,10 @@ func (p *pointer) NotNil() bool { func (p *pointer) Valid(v interface{}) error { p2 := getPointers(v) if p.Fist != p2.Fist { - return ErrFirstPtrChanged + return errFirstPtrChanged } if p.Second != 0 && p2.Second != 0 && p2.Second == p.Second { - return ErrSecondPtrNotChanged + return errSecondPtrNotChanged } return nil } diff --git a/marshal/tests/serialization/pointers_test.go b/internal/tests/serialization/pointers_test.go similarity index 100% rename from marshal/tests/serialization/pointers_test.go rename to internal/tests/serialization/pointers_test.go diff --git a/marshal/tests/serialization/set.go b/internal/tests/serialization/set.go similarity index 78% rename from marshal/tests/serialization/set.go rename to internal/tests/serialization/set.go index b26bc8dcd..653815ff5 100644 --- a/marshal/tests/serialization/set.go +++ b/internal/tests/serialization/set.go @@ -7,12 +7,8 @@ import ( "reflect" "runtime/debug" "testing" - - "github.com/gocql/gocql/internal/tests/utils" ) -type Sets []*Set - // Set is a tool for marshal and unmarshall funcs testing. type Set struct { Data []byte @@ -22,6 +18,9 @@ type Set struct { BrokenUnmarshalTypes []reflect.Type } +// RunTest runs tests for cases when the function should no error, +// on marshal - marshaled data from Set.Values should be equal with Set.Data, +// on unmarshall - unmarshalled value from Set.Data should be equal with Set.Values. func (s Set) RunTest(name string, t *testing.T, marshal func(interface{}) ([]byte, error), unmarshal func([]byte, interface{}) error) { if name == "" { t.Fatal("name should be provided") @@ -38,15 +37,15 @@ func (s Set) RunTest(name string, t *testing.T, marshal func(interface{}) ([]byt if unmarshal != nil { if rt := reflect.TypeOf(val); rt.Kind() != reflect.Ptr { - unmarshalIn := utils.NewRef(val) + unmarshalIn := newRef(val) s.runUnmarshalTest("unmarshal", t, unmarshal, val, unmarshalIn) } else { // Test unmarshal to (*type)(nil) - unmarshalIn := utils.NewRef(val) + unmarshalIn := newRef(val) s.runUnmarshalTest("unmarshal**nil", t, unmarshal, val, unmarshalIn) // Test unmarshal to &type{} - unmarshalInZero := utils.NewRefToZero(val) + unmarshalInZero := newRefToZero(val) s.runUnmarshalTest("unmarshal**zero", t, unmarshal, val, unmarshalInZero) } } @@ -68,22 +67,22 @@ func (s Set) RunCorruptTest(name string, t *testing.T, marshal func(interface{}) val := s.Values[m] if marshal != nil { - t.Run(utils.StringValue(val), func(t *testing.T) { + t.Run(stringValue(val), func(t *testing.T) { s.runMarshalCorruptTest(t, marshal, val) }) continue } if rt := reflect.TypeOf(val); rt.Kind() != reflect.Ptr { - unmarshalIn := utils.NewRef(val) + unmarshalIn := newRef(val) s.runUnmarshalCorruptTest(fmt.Sprintf("%T", val), t, unmarshal, val, unmarshalIn) } else { // Test unmarshal to (*type)(nil) - unmarshalIn := utils.NewRef(val) + unmarshalIn := newRef(val) s.runUnmarshalCorruptTest(fmt.Sprintf("%T**nil", val), t, unmarshal, val, unmarshalIn) // Test unmarshal to &type{} - unmarshalInZero := utils.NewRefToZero(val) + unmarshalInZero := newRefToZero(val) s.runUnmarshalCorruptTest(fmt.Sprintf("%T**zero", val), t, unmarshal, val, unmarshalInZero) } } @@ -96,7 +95,7 @@ func (s Set) runMarshalTest(t *testing.T, f func(interface{}) ([]byte, error), v result, err := func() (d []byte, err error) { defer func() { if r := recover(); r != nil { - err = utils.PanicErr{Err: r.(error), Stack: debug.Stack()} + err = panicErr{err: r.(error), stack: debug.Stack()} } }() return f(val) @@ -104,11 +103,11 @@ func (s Set) runMarshalTest(t *testing.T, f func(interface{}) ([]byte, error), v expected := bytes.Clone(s.Data) if err != nil { - if !errors.As(err, &utils.PanicErr{}) { - err = errors.Join(MarshalErr, err) + if !errors.As(err, &panicErr{}) { + err = errors.Join(marshalErr, err) } - } else if !utils.EqualData(expected, result) { - err = UnequalError{Expected: utils.StringData(s.Data), Got: utils.StringData(result)} + } else if !equalData(expected, result) { + err = unequalError{Expected: stringData(s.Data), Got: stringData(result)} } if isTypeOf(val, s.BrokenMarshalTypes) { @@ -131,18 +130,18 @@ func (s Set) runUnmarshalTest(name string, t *testing.T, f func([]byte, interfac err := func() (err error) { defer func() { if r := recover(); r != nil { - err = utils.PanicErr{Err: fmt.Errorf("%s", r), Stack: debug.Stack()} + err = panicErr{err: fmt.Errorf("%s", r), stack: debug.Stack()} } }() return f(bytes.Clone(s.Data), result) }() if err != nil { - if !errors.As(err, &utils.PanicErr{}) { - err = errors.Join(UnmarshalErr, err) + if !errors.As(err, &panicErr{}) { + err = errors.Join(unmarshalErr, err) } - } else if !utils.EqualVals(expected, utils.DeReference(result)) { - err = UnequalError{Expected: utils.StringValue(expected), Got: utils.StringValue(result)} + } else if !equalVals(expected, deReference(result)) { + err = unequalError{Expected: stringValue(expected), Got: stringValue(result)} } else { err = expectedPtr.Valid(result) } @@ -163,14 +162,15 @@ func (s Set) runMarshalCorruptTest(t *testing.T, f func(interface{}) ([]byte, er _, err := func() (d []byte, err error) { defer func() { if r := recover(); r != nil { - err = utils.PanicErr{Err: r.(error), Stack: debug.Stack()} + err = panicErr{err: r.(error), stack: debug.Stack()} } }() return f(val) }() testFailed := false - if err == nil || errors.As(err, &utils.PanicErr{}) { + wasPanic := errors.As(err, &panicErr{}) + if err == nil || wasPanic { testFailed = true } @@ -182,7 +182,7 @@ func (s Set) runMarshalCorruptTest(t *testing.T, f func(interface{}) ([]byte, er } if testFailed { - if errors.As(err, &utils.PanicErr{}) { + if wasPanic { t.Fatalf("was panic %s", err) } t.Errorf("expected an error for (%T), but got no error", val) @@ -194,14 +194,15 @@ func (s Set) runUnmarshalCorruptTest(name string, t *testing.T, f func([]byte, i err := func() (err error) { defer func() { if r := recover(); r != nil { - err = utils.PanicErr{Err: r.(error), Stack: debug.Stack()} + err = panicErr{err: r.(error), stack: debug.Stack()} } }() return f(bytes.Clone(s.Data), unmarshalIn) }() testFailed := false - if err == nil || errors.As(err, &utils.PanicErr{}) { + wasPanic := errors.As(err, &panicErr{}) + if err == nil || wasPanic { testFailed = true } @@ -213,7 +214,7 @@ func (s Set) runUnmarshalCorruptTest(name string, t *testing.T, f func([]byte, i } if testFailed { - if errors.As(err, &utils.PanicErr{}) { + if wasPanic { t.Fatalf("was panic %s", err) } t.Errorf("expected an error for (%T), but got no error", unmarshalIn) diff --git a/internal/tests/utils/utils.go b/internal/tests/serialization/utils.go similarity index 51% rename from internal/tests/utils/utils.go rename to internal/tests/serialization/utils.go index 6b2239b48..667efe993 100644 --- a/internal/tests/utils/utils.go +++ b/internal/tests/serialization/utils.go @@ -1,19 +1,9 @@ -package utils +package serialization import ( "reflect" ) -func DeReference(in interface{}) interface{} { - return reflect.Indirect(reflect.ValueOf(in)).Interface() -} - -func Reference(val interface{}) interface{} { - out := reflect.New(reflect.TypeOf(val)) - out.Elem().Set(reflect.ValueOf(val)) - return out.Interface() -} - func GetTypes(values ...interface{}) []reflect.Type { types := make([]reflect.Type, len(values)) for i, value := range values { @@ -21,3 +11,17 @@ func GetTypes(values ...interface{}) []reflect.Type { } return types } + +func isTypeOf(value interface{}, types []reflect.Type) bool { + valueType := reflect.TypeOf(value) + for i := range types { + if types[i] == valueType { + return true + } + } + return false +} + +func deReference(in interface{}) interface{} { + return reflect.Indirect(reflect.ValueOf(in)).Interface() +} diff --git a/internal/tests/utils/equal.go b/internal/tests/serialization/utils_equal.go similarity index 91% rename from internal/tests/utils/equal.go rename to internal/tests/serialization/utils_equal.go index 71e48af80..9acf5035a 100644 --- a/internal/tests/utils/equal.go +++ b/internal/tests/serialization/utils_equal.go @@ -1,24 +1,23 @@ -package utils +package serialization import ( "bytes" "fmt" + "github.com/gocql/gocql/internal/tests/serialization/mod" "gopkg.in/inf.v0" "math/big" "reflect" "unsafe" - - "github.com/gocql/gocql/marshal/tests/mod" ) -func EqualData(in1, in2 []byte) bool { +func equalData(in1, in2 []byte) bool { if in1 == nil || in2 == nil { return in1 == nil && in2 == nil } return bytes.Equal(in1, in2) } -func EqualVals(in1, in2 interface{}) bool { +func equalVals(in1, in2 interface{}) bool { rin1 := reflect.ValueOf(in1) rin2 := reflect.ValueOf(in2) if rin1.Kind() != rin2.Kind() { diff --git a/internal/tests/serialization/utils_error.go b/internal/tests/serialization/utils_error.go new file mode 100644 index 000000000..12b4ff3f4 --- /dev/null +++ b/internal/tests/serialization/utils_error.go @@ -0,0 +1,27 @@ +package serialization + +import ( + "errors" + "fmt" +) + +var unmarshalErr = errors.New("unmarshal unexpectedly failed with error") +var marshalErr = errors.New("marshal unexpectedly failed with error") + +type unequalError struct { + Expected string + Got string +} + +func (e unequalError) Error() string { + return fmt.Sprintf("expect %s but got %s", e.Expected, e.Got) +} + +type panicErr struct { + err error + stack []byte +} + +func (e panicErr) Error() string { + return fmt.Sprintf("%v\n%s", e.err, e.stack) +} diff --git a/internal/tests/utils/new.go b/internal/tests/serialization/utils_new.go similarity index 67% rename from internal/tests/utils/new.go rename to internal/tests/serialization/utils_new.go index d2901db01..a821272ed 100644 --- a/internal/tests/utils/new.go +++ b/internal/tests/serialization/utils_new.go @@ -1,15 +1,15 @@ -package utils +package serialization import ( "reflect" ) -func NewRef(in interface{}) interface{} { +func newRef(in interface{}) interface{} { out := reflect.New(reflect.TypeOf(in)).Interface() return out } -func NewRefToZero(in interface{}) interface{} { +func newRefToZero(in interface{}) interface{} { rv := reflect.ValueOf(in) nw := reflect.New(rv.Type().Elem()) out := reflect.New(rv.Type()) diff --git a/internal/tests/utils/string_vals.go b/internal/tests/serialization/utils_str.go similarity index 69% rename from internal/tests/utils/string_vals.go rename to internal/tests/serialization/utils_str.go index 73bbf19ee..3634224ec 100644 --- a/internal/tests/utils/string_vals.go +++ b/internal/tests/serialization/utils_str.go @@ -1,4 +1,4 @@ -package utils +package serialization import ( "fmt" @@ -9,16 +9,25 @@ import ( "time" ) -// StringValue returns (value_type)(value) in the human-readable format. -func StringValue(in interface{}) string { - valStr := stringValue(in) +const printLimit = 100 + +// stringValue returns (value_type)(value) in the human-readable format. +func stringValue(in interface{}) string { + valStr := stringVal(in) if len(valStr) > printLimit { valStr = valStr[:printLimit] } return fmt.Sprintf("(%T)(%s)", in, valStr) } -func stringValue(in interface{}) string { +func stringData(p []byte) string { + if len(p) > printLimit { + p = p[:printLimit] + } + return fmt.Sprintf("[%x]", p) +} + +func stringVal(in interface{}) string { switch i := in.(type) { case string: return i @@ -40,7 +49,7 @@ func stringValue(in interface{}) string { if rv.IsNil() { return "*nil" } - return fmt.Sprintf("*%s", stringValue(rv.Elem().Interface())) + return fmt.Sprintf("*%s", stringVal(rv.Elem().Interface())) case reflect.Slice: if rv.IsNil() { return "[nil]" diff --git a/internal/tests/utils/panic_err.go b/internal/tests/utils/panic_err.go deleted file mode 100644 index 45d27cb9c..000000000 --- a/internal/tests/utils/panic_err.go +++ /dev/null @@ -1,14 +0,0 @@ -package utils - -import ( - "fmt" -) - -type PanicErr struct { - Err error - Stack []byte -} - -func (e PanicErr) Error() string { - return fmt.Sprintf("%v\n%s", e.Err, e.Stack) -} diff --git a/internal/tests/utils/string.go b/internal/tests/utils/string.go deleted file mode 100644 index 8d7712518..000000000 --- a/internal/tests/utils/string.go +++ /dev/null @@ -1,14 +0,0 @@ -package utils - -import ( - "fmt" -) - -const printLimit = 100 - -func StringData(p []byte) string { - if len(p) > printLimit { - p = p[:printLimit] - } - return fmt.Sprintf("[%x]", p) -} diff --git a/marshal/tests/serialization/utils.go b/marshal/tests/serialization/utils.go deleted file mode 100644 index 63010dd56..000000000 --- a/marshal/tests/serialization/utils.go +++ /dev/null @@ -1,29 +0,0 @@ -package serialization - -import ( - "errors" - "fmt" - "reflect" -) - -var UnmarshalErr = errors.New("unmarshal unexpectedly failed with error") -var MarshalErr = errors.New("marshal unexpectedly failed with error") - -type UnequalError struct { - Expected string - Got string -} - -func (e UnequalError) Error() string { - return fmt.Sprintf("expect %s but got %s", e.Expected, e.Got) -} - -func isTypeOf(value interface{}, types []reflect.Type) bool { - valueType := reflect.TypeOf(value) - for i := range types { - if types[i] == valueType { - return true - } - } - return false -} diff --git a/marshal_10_decimal_test.go b/marshal_10_decimal_test.go index 84b5ce72c..a773d639f 100644 --- a/marshal_10_decimal_test.go +++ b/marshal_10_decimal_test.go @@ -6,9 +6,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalDecimal(t *testing.T) { diff --git a/marshal_1_boolean_test.go b/marshal_1_boolean_test.go index b451d880c..d495b2f0c 100644 --- a/marshal_1_boolean_test.go +++ b/marshal_1_boolean_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalBoolean(t *testing.T) { diff --git a/marshal_2_tinyint_test.go b/marshal_2_tinyint_test.go index ad8264a0c..65b6c7deb 100644 --- a/marshal_2_tinyint_test.go +++ b/marshal_2_tinyint_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalTinyint(t *testing.T) { @@ -19,15 +18,15 @@ func TestMarshalTinyint(t *testing.T) { } // unmarshal `custom string` unsupported - brokenCustomStrings := utils.GetTypes(mod.String(""), (*mod.String)(nil)) + brokenCustomStrings := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) // marshal "" (empty string) unsupported // unmarshal nil value into (string)("0") - brokenEmptyStrings := utils.GetTypes(string(""), mod.String("")) + brokenEmptyStrings := serialization.GetTypes(string(""), mod.String("")) // marshal `custom string` unsupported // marshal `big.Int` unsupported - brokenMarshalTypes := append(brokenCustomStrings, utils.GetTypes(big.Int{}, &big.Int{})...) + brokenMarshalTypes := append(brokenCustomStrings, serialization.GetTypes(big.Int{}, &big.Int{})...) serialization.Set{ Data: nil, diff --git a/marshal_3_smallint_corrupt_test.go b/marshal_3_smallint_corrupt_test.go index 015c8209a..b02ba4afd 100644 --- a/marshal_3_smallint_corrupt_test.go +++ b/marshal_3_smallint_corrupt_test.go @@ -1,27 +1,29 @@ -package gocql +package gocql_test import ( "math/big" "testing" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalSmallintCorrupt(t *testing.T) { - marshal := func(i interface{}) ([]byte, error) { return Marshal(NativeType{proto: 4, typ: TypeSmallInt}, i) } + tType := gocql.NewNativeType(4, gocql.TypeSmallInt, "") + + marshal := func(i interface{}) ([]byte, error) { return gocql.Marshal(tType, i) } unmarshal := func(bytes []byte, i interface{}) error { - return Unmarshal(NativeType{proto: 4, typ: TypeSmallInt}, bytes, i) + return gocql.Unmarshal(tType, bytes, i) } - brokenUnmarshalTypes := utils.GetTypes( + brokenUnmarshalTypes := serialization.GetTypes( mod.Values{ int8(0), int16(0), int32(0), int64(0), int(0), uint8(0), uint16(0), uint32(0), uint64(0), uint(0), *big.NewInt(0), }.AddVariants(mod.All...)...) - brokenUnmarshalTypes = append(brokenUnmarshalTypes, utils.GetTypes("", (*string)(nil))...) + brokenUnmarshalTypes = append(brokenUnmarshalTypes, serialization.GetTypes("", (*string)(nil))...) serialization.Set{ Values: mod.Values{ diff --git a/marshal_3_smallint_test.go b/marshal_3_smallint_test.go index 4d4d12773..3dc495f13 100644 --- a/marshal_3_smallint_test.go +++ b/marshal_3_smallint_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalSmallint(t *testing.T) { @@ -19,15 +18,15 @@ func TestMarshalSmallint(t *testing.T) { } // unmarshal `custom string` unsupported - brokenCustomStrings := utils.GetTypes(mod.String(""), (*mod.String)(nil)) + brokenCustomStrings := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) // marshal "" (empty string) unsupported // unmarshal nil value into (string)("0") - brokenEmptyStrings := utils.GetTypes(string(""), mod.String("")) + brokenEmptyStrings := serialization.GetTypes(string(""), mod.String("")) // marshal `custom string` unsupported // marshal `big.Int` unsupported - brokenMarshalTypes := append(brokenCustomStrings, utils.GetTypes(big.Int{}, &big.Int{})...) + brokenMarshalTypes := append(brokenCustomStrings, serialization.GetTypes(big.Int{}, &big.Int{})...) serialization.Set{ Data: nil, diff --git a/marshal_4_int_test.go b/marshal_4_int_test.go index 312348a73..77540adbb 100644 --- a/marshal_4_int_test.go +++ b/marshal_4_int_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalInt(t *testing.T) { @@ -19,18 +18,18 @@ func TestMarshalInt(t *testing.T) { } // unmarshal `custom string` unsupported - brokenCustomStrings := utils.GetTypes(mod.String(""), (*mod.String)(nil)) + brokenCustomStrings := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) // marshal "" (empty string) unsupported // unmarshal nil value into (string)("0") - brokenEmptyStrings := utils.GetTypes(string(""), mod.String("")) + brokenEmptyStrings := serialization.GetTypes(string(""), mod.String("")) // marshal `custom string` unsupported // marshal `big.Int` unsupported - brokenMarshalTypes := append(brokenCustomStrings, utils.GetTypes(big.Int{}, &big.Int{})...) + brokenMarshalTypes := append(brokenCustomStrings, serialization.GetTypes(big.Int{}, &big.Int{})...) // marshal data, which equal math.MaxUint32, into uint32, uit64, uint leads to an error - brokenUints := utils.GetTypes(mod.Uint32(0), mod.Uint64(0), mod.Uint(0), (*mod.Uint32)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) + brokenUints := serialization.GetTypes(mod.Uint32(0), mod.Uint64(0), mod.Uint(0), (*mod.Uint32)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) serialization.Set{ Data: nil, diff --git a/marshal_5_bigint_test.go b/marshal_5_bigint_test.go index 39739682b..528a8daac 100644 --- a/marshal_5_bigint_test.go +++ b/marshal_5_bigint_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalBigInt(t *testing.T) { @@ -19,18 +18,18 @@ func TestMarshalBigInt(t *testing.T) { } // unmarshal `custom string` unsupported - brokenCustomStrings := utils.GetTypes(mod.String(""), (*mod.String)(nil)) + brokenCustomStrings := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) // marshal "" (empty string) unsupported // unmarshal nil value into (string)("0") - brokenEmptyStrings := utils.GetTypes(string(""), mod.String("")) + brokenEmptyStrings := serialization.GetTypes(string(""), mod.String("")) // marshal `custom string` unsupported // marshal `big.Int` unsupported - brokenMarshalTypes := append(brokenCustomStrings, utils.GetTypes(big.Int{}, &big.Int{})...) + brokenMarshalTypes := append(brokenCustomStrings, serialization.GetTypes(big.Int{}, &big.Int{})...) // marshal data, which equal math.MaxUint64, into uint and uit64 leads to an error - brokenUints := utils.GetTypes(uint(0), mod.Uint64(0), mod.Uint(0), (*uint)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) + brokenUints := serialization.GetTypes(uint(0), mod.Uint64(0), mod.Uint(0), (*uint)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) serialization.Set{ Data: nil, diff --git a/marshal_6_counter_test.go b/marshal_6_counter_test.go index 9f3e3a9bd..3f1dd1b25 100644 --- a/marshal_6_counter_test.go +++ b/marshal_6_counter_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalCounter(t *testing.T) { @@ -19,18 +18,18 @@ func TestMarshalCounter(t *testing.T) { } // unmarshal `custom string` unsupported - brokenCustomStrings := utils.GetTypes(mod.String(""), (*mod.String)(nil)) + brokenCustomStrings := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) // marshal "" (empty string) unsupported // unmarshal nil value into (string)("0") - brokenEmptyStrings := utils.GetTypes(string(""), mod.String("")) + brokenEmptyStrings := serialization.GetTypes(string(""), mod.String("")) // marshal `custom string` unsupported // marshal `big.Int` unsupported - brokenMarshalTypes := append(brokenCustomStrings, utils.GetTypes(big.Int{}, &big.Int{})...) + brokenMarshalTypes := append(brokenCustomStrings, serialization.GetTypes(big.Int{}, &big.Int{})...) // marshal data, which equal math.MaxUint64, into uint and uit64 leads to an error - brokenUints := utils.GetTypes(uint(0), mod.Uint64(0), mod.Uint(0), (*uint)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) + brokenUints := serialization.GetTypes(uint(0), mod.Uint64(0), mod.Uint(0), (*uint)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) serialization.Set{ Data: nil, diff --git a/marshal_7_varint_test.go b/marshal_7_varint_test.go index 2b4b6e6f4..2badeda7f 100644 --- a/marshal_7_varint_test.go +++ b/marshal_7_varint_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/internal/tests/utils" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalVarInt(t *testing.T) { @@ -19,17 +18,17 @@ func TestMarshalVarInt(t *testing.T) { } // unmarshal `custom string` unsupported - brokenCustomStrings := utils.GetTypes(mod.String(""), (*mod.String)(nil)) + brokenCustomStrings := serialization.GetTypes(mod.String(""), (*mod.String)(nil)) // marshal "" (empty string) unsupported // unmarshal nil value into (string)("0") - brokenEmptyStrings := utils.GetTypes(string(""), mod.String("")) + brokenEmptyStrings := serialization.GetTypes(string(""), mod.String("")) // marshal data, which equal math.MaxUint64, into uint and uit64 leads to an error - brokenUints := utils.GetTypes(uint(0), mod.Uint64(0), mod.Uint(0), (*uint)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) + brokenUints := serialization.GetTypes(uint(0), mod.Uint64(0), mod.Uint(0), (*uint)(nil), (*mod.Uint64)(nil), (*mod.Uint)(nil)) // marshal and unmarshal all strings with data or value which out of range of int64 unsupported - brokenBigStrings := utils.GetTypes(string(""), (*string)(nil), mod.String(""), (*mod.String)(nil)) + brokenBigStrings := serialization.GetTypes(string(""), (*string)(nil), mod.String(""), (*mod.String)(nil)) serialization.Set{ Data: nil, diff --git a/marshal_8_float_test.go b/marshal_8_float_test.go index 586c01eb0..7867c0a82 100644 --- a/marshal_8_float_test.go +++ b/marshal_8_float_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalFloat(t *testing.T) { diff --git a/marshal_9_duble_test.go b/marshal_9_duble_test.go index 60da036dd..a45cce36d 100644 --- a/marshal_9_duble_test.go +++ b/marshal_9_duble_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/gocql/gocql/marshal/tests/mod" - "github.com/gocql/gocql/marshal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization" + "github.com/gocql/gocql/internal/tests/serialization/mod" ) func TestMarshalDouble(t *testing.T) {