forked from apache/cassandra-gocql-driver
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
join and move
serialization
and utils
packages
`serialization` and `utils` packages are joined and moved to `internal/tests/serialization`
- Loading branch information
Showing
28 changed files
with
144 additions
and
170 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 15 additions & 11 deletions
26
internal/tests/utils/utils.go → internal/tests/serialization/utils.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
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 { | ||
types[i] = reflect.TypeOf(value) | ||
} | ||
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() | ||
} |
9 changes: 4 additions & 5 deletions
9
internal/tests/utils/equal.go → internal/tests/serialization/utils_equal.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
6 changes: 3 additions & 3 deletions
6
internal/tests/utils/new.go → internal/tests/serialization/utils_new.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.