mirror of
https://github.com/asdine/storm.git
synced 2025-10-26 16:40:23 +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
|
||||
|
||||
// EncodeDecoder represents a codec used to encode and decode entities.
|
||||
|
||||
@@ -3,9 +3,9 @@ package json
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/asdine/storm/codec"
|
||||
"github.com/asdine/storm/codec/internal"
|
||||
)
|
||||
|
||||
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
|
||||
// to encode and decode entities in Storm.
|
||||
package codec
|
||||
package internal
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/asdine/storm/codec"
|
||||
)
|
||||
|
||||
type testStruct struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
// RountripTester is a test helper to test a EncodeDecoder
|
||||
func RountripTester(t *testing.T, c EncodeDecoder, vals ...interface{}) {
|
||||
// RoundtripTester is a test helper to test a EncodeDecoder
|
||||
func RoundtripTester(t *testing.T, c codec.EncodeDecoder, vals ...interface{}) {
|
||||
var val, to interface{}
|
||||
if len(vals) > 0 {
|
||||
if len(vals) != 2 {
|
||||
@@ -3,9 +3,9 @@ package json
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/asdine/storm/codec"
|
||||
"github.com/asdine/storm/codec/internal"
|
||||
)
|
||||
|
||||
func TestJSON(t *testing.T) {
|
||||
codec.RountripTester(t, Codec)
|
||||
internal.RoundtripTester(t, Codec)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package sereal
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/asdine/storm/codec"
|
||||
"github.com/asdine/storm/codec/internal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -16,6 +16,6 @@ func TestSereal(t *testing.T) {
|
||||
u1 := &SerealUser{Name: "Sereal"}
|
||||
u1.Self = u1 // cyclic ref
|
||||
u2 := &SerealUser{}
|
||||
codec.RountripTester(t, Codec, &u1, &u2)
|
||||
internal.RoundtripTester(t, Codec, &u1, &u2)
|
||||
assert.True(t, u2 == u2.Self)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user