diff --git a/uuid/msgpack_helper_test.go b/uuid/msgpack_helper_test.go index d5a1cb70e..8ace10297 100644 --- a/uuid/msgpack_helper_test.go +++ b/uuid/msgpack_helper_test.go @@ -8,3 +8,11 @@ import ( ) type decoder = msgpack.Decoder + +func marshal(v interface{}) ([]byte, error) { + return msgpack.Marshal(v) +} + +func unmarshal(data []byte, v interface{}) error { + return msgpack.Unmarshal(data, v) +} diff --git a/uuid/msgpack_v5_helper_test.go b/uuid/msgpack_v5_helper_test.go index c2356ef1a..3ba2c3cd4 100644 --- a/uuid/msgpack_v5_helper_test.go +++ b/uuid/msgpack_v5_helper_test.go @@ -8,3 +8,11 @@ import ( ) type decoder = msgpack.Decoder + +func marshal(v interface{}) ([]byte, error) { + return msgpack.Marshal(v) +} + +func unmarshal(data []byte, v interface{}) error { + return msgpack.Unmarshal(data, v) +} diff --git a/uuid/uuid_test.go b/uuid/uuid_test.go index 6224a938b..2795b9128 100644 --- a/uuid/uuid_test.go +++ b/uuid/uuid_test.go @@ -133,6 +133,30 @@ func TestReplace(t *testing.T) { tupleValueIsId(t, respSel.Data, id) } +type marshalComplexTuple struct { + UUID uuid.UUID + Name string +} + +func TestMarshalComplex(t *testing.T) { + space := marshalComplexTuple{UUID: uuid.New(), Name: "foo bar"} + + b, err := marshal(&space) + if err != nil { + t.Fatalf("Unable to marshal: %s", err) + } + + var item marshalComplexTuple + err = unmarshal(b, &item) + if err != nil { + t.Fatalf("Unable to unmarshal: %s", err) + } + + if item.Name != space.Name { + t.Fatalf("names is not equal: %s != %s", space.Name, item.Name) + } +} + // runTestMain is a body of TestMain function // (see https://pkg.go.dev/testing#hdr-Main). // Using defer + os.Exit is not works so TestMain body