|
|
@@ -10,6 +10,7 @@ package codec
|
|
|
// so we only use maps with string keys here.
|
|
|
|
|
|
import (
|
|
|
+ "bytes"
|
|
|
"math"
|
|
|
"strings"
|
|
|
"time"
|
|
|
@@ -17,10 +18,14 @@ import (
|
|
|
|
|
|
type wrapSliceUint64 []uint64
|
|
|
type wrapSliceString []string
|
|
|
+type wrapUint8 uint8
|
|
|
+type wrapInt64 int64
|
|
|
type wrapUint64 uint64
|
|
|
type wrapString string
|
|
|
type wrapUint64Slice []wrapUint64
|
|
|
type wrapStringSlice []wrapString
|
|
|
+type wrapBytes []uint8
|
|
|
+type wrapBytesSlice []wrapBytes
|
|
|
|
|
|
type stringUint64T struct {
|
|
|
S string
|
|
|
@@ -157,6 +162,13 @@ type testStrucCommon struct {
|
|
|
// make this one omitempty (so it is excluded if nil).
|
|
|
*AnonInTestStrucIntf `codec:",omitempty"`
|
|
|
|
|
|
+ Ci64 wrapInt64
|
|
|
+ Swrapbytes []wrapBytes
|
|
|
+ Swrapuint8 []wrapUint8
|
|
|
+
|
|
|
+ // R Raw // Testing Raw must be explicitly turned on, so use standalone test
|
|
|
+ // Rext RawExt // Testing RawExt is tricky, so use standalone test
|
|
|
+
|
|
|
Nmap map[string]bool //don't set this, so we can test for nil
|
|
|
Nslice []byte //don't set this, so we can test for nil
|
|
|
Nint64 *int64 //don't set this, so we can test for nil
|
|
|
@@ -343,6 +355,25 @@ func populateTestStrucCommon(ts *testStrucCommon, n int, bench, useInterface, us
|
|
|
WrapSliceInt64: []uint64{4, 16, 64, 256},
|
|
|
WrapSliceString: []string{strRpt(n, "4"), strRpt(n, "16"), strRpt(n, "64"), strRpt(n, "256")},
|
|
|
|
|
|
+ Ci64: -22,
|
|
|
+ Swrapbytes: []wrapBytes{ // lengths of 1, 2, 4, 8, 16, 32, 64, 128, 256,
|
|
|
+ wstrRpt(1, "A"),
|
|
|
+ wstrRpt(2, "A"),
|
|
|
+ wstrRpt(4, "A"),
|
|
|
+ wstrRpt(8, "A"),
|
|
|
+ wstrRpt(16, "A"),
|
|
|
+ wstrRpt(32, "A"),
|
|
|
+ wstrRpt(64, "A"),
|
|
|
+ wstrRpt(128, "A"),
|
|
|
+ wstrRpt(256, "A"),
|
|
|
+ wstrRpt(512, "A"),
|
|
|
+ },
|
|
|
+ Swrapuint8: []wrapUint8{
|
|
|
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
|
|
+ },
|
|
|
+ // R: Raw([]byte("goodbye")),
|
|
|
+ // Rext: RawExt{ 120, []byte("hello"), }, // TODO: don't set this - it's hard to test
|
|
|
+
|
|
|
// DecodeNaked bombs here, because the stringUint64T is decoded as a map,
|
|
|
// and a map cannot be the key type of a map.
|
|
|
// Thus, don't initialize this here.
|
|
|
@@ -352,6 +383,7 @@ func populateTestStrucCommon(ts *testStrucCommon, n int, bench, useInterface, us
|
|
|
// },
|
|
|
|
|
|
// make Simplef same as top-level
|
|
|
+ // TODO: should this have slightly different values???
|
|
|
Simplef: testSimpleFields{
|
|
|
S: strRpt(n, `some really really cool names that are nigerian and american like "ugorji melody nwoke" - get it? `),
|
|
|
|
|
|
@@ -450,3 +482,7 @@ func newTestStruc(depth, n int, bench, useInterface, useStringKeyOnly bool) (ts
|
|
|
func strRpt(n int, s string) string {
|
|
|
return strings.Repeat(s, n)
|
|
|
}
|
|
|
+
|
|
|
+func wstrRpt(n int, s string) wrapBytes {
|
|
|
+ return wrapBytes(bytes.Repeat([]byte(s), n))
|
|
|
+}
|