mirror of
https://github.com/asdine/storm.git
synced 2025-10-29 01:22:29 +08:00
Move codec test helper to an internal package
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
// Package codec contains sub-packages with different codecs that can be used
|
||||||
|
// to encode and decode entities in Storm.
|
||||||
package codec
|
package codec
|
||||||
|
|
||||||
// EncodeDecoder represents a codec used to encode and decode entities.
|
// EncodeDecoder represents a codec used to encode and decode entities.
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package json
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/asdine/storm/codec"
|
"github.com/asdine/storm/codec/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGob(t *testing.T) {
|
func TestGob(t *testing.T) {
|
||||||
codec.RountripTester(t, Codec)
|
internal.RoundtripTester(t, Codec)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
// Package codec contains sub-packages with different codecs that can be used
|
package internal
|
||||||
// to encode and decode entities in Storm.
|
|
||||||
package codec
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/asdine/storm/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testStruct struct {
|
type testStruct struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// RountripTester is a test helper to test a EncodeDecoder
|
// RoundtripTester is a test helper to test a EncodeDecoder
|
||||||
func RountripTester(t *testing.T, c EncodeDecoder, vals ...interface{}) {
|
func RoundtripTester(t *testing.T, c codec.EncodeDecoder, vals ...interface{}) {
|
||||||
var val, to interface{}
|
var val, to interface{}
|
||||||
if len(vals) > 0 {
|
if len(vals) > 0 {
|
||||||
if len(vals) != 2 {
|
if len(vals) != 2 {
|
||||||
@@ -3,9 +3,9 @@ package json
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/asdine/storm/codec"
|
"github.com/asdine/storm/codec/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestJSON(t *testing.T) {
|
func TestJSON(t *testing.T) {
|
||||||
codec.RountripTester(t, Codec)
|
internal.RoundtripTester(t, Codec)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package sereal
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/asdine/storm/codec"
|
"github.com/asdine/storm/codec/internal"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +16,6 @@ func TestSereal(t *testing.T) {
|
|||||||
u1 := &SerealUser{Name: "Sereal"}
|
u1 := &SerealUser{Name: "Sereal"}
|
||||||
u1.Self = u1 // cyclic ref
|
u1.Self = u1 // cyclic ref
|
||||||
u2 := &SerealUser{}
|
u2 := &SerealUser{}
|
||||||
codec.RountripTester(t, Codec, &u1, &u2)
|
internal.RoundtripTester(t, Codec, &u1, &u2)
|
||||||
assert.True(t, u2 == u2.Self)
|
assert.True(t, u2 == u2.Self)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user