diff --git a/vendor/github.com/ugorji/go/codec/LICENSE b/vendor/github.com/ugorji/go/codec/LICENSE new file mode 100644 index 0000000000..95a0f0541c --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2012-2015 Ugorji Nwoke. +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/ugorji/go/codec/README.md b/vendor/github.com/ugorji/go/codec/README.md deleted file mode 100644 index cadc41b4ca..0000000000 --- a/vendor/github.com/ugorji/go/codec/README.md +++ /dev/null @@ -1,166 +0,0 @@ -# Codec - -High Performance, Feature-Rich Idiomatic Go codec/encoding library for -binc, msgpack, cbor, json. - -Supported Serialization formats are: - - - msgpack: https://github.com/msgpack/msgpack - - binc: http://github.com/ugorji/binc - - cbor: http://cbor.io http://tools.ietf.org/html/rfc7049 - - json: http://json.org http://tools.ietf.org/html/rfc7159 - - simple: - -To install: - - go get github.com/ugorji/go/codec - -This package will carefully use 'unsafe' for performance reasons in specific places. -You can build without unsafe use by passing the safe or appengine tag -i.e. 'go install -tags=safe ...'. Note that unsafe is only supported for the last 3 -go sdk versions e.g. current go release is go 1.9, so we support unsafe use only from -go 1.7+ . This is because supporting unsafe requires knowledge of implementation details. - -Online documentation: http://godoc.org/github.com/ugorji/go/codec -Detailed Usage/How-to Primer: http://ugorji.net/blog/go-codec-primer - -The idiomatic Go support is as seen in other encoding packages in -the standard library (ie json, xml, gob, etc). - -Rich Feature Set includes: - - - Simple but extremely powerful and feature-rich API - - Support for go1.4 and above, while selectively using newer APIs for later releases - - Good code coverage ( > 70% ) - - Very High Performance. - Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X. - - Careful selected use of 'unsafe' for targeted performance gains. - 100% mode exists where 'unsafe' is not used at all. - - Lock-free (sans mutex) concurrency for scaling to 100's of cores - - Multiple conversions: - Package coerces types where appropriate - e.g. decode an int in the stream into a float, etc. - - Corner Cases: - Overflows, nil maps/slices, nil values in streams are handled correctly - - Standard field renaming via tags - - Support for omitting empty fields during an encoding - - Encoding from any value and decoding into pointer to any value - (struct, slice, map, primitives, pointers, interface{}, etc) - - Extensions to support efficient encoding/decoding of any named types - - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces - - Decoding without a schema (into a interface{}). - Includes Options to configure what specific map or slice type to use - when decoding an encoded list or map into a nil interface{} - - Encode a struct as an array, and decode struct from an array in the data stream - - Comprehensive support for anonymous fields - - Fast (no-reflection) encoding/decoding of common maps and slices - - Code-generation for faster performance. - - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats - - Support indefinite-length formats to enable true streaming - (for formats which support it e.g. json, cbor) - - Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes. - This mostly applies to maps, where iteration order is non-deterministic. - - NIL in data stream decoded as zero value - - Never silently skip data when decoding. - User decides whether to return an error or silently skip data when keys or indexes - in the data stream do not map to fields in the struct. - - Encode/Decode from/to chan types (for iterative streaming support) - - Drop-in replacement for encoding/json. `json:` key in struct tag supported. - - Provides a RPC Server and Client Codec for net/rpc communication protocol. - - Handle unique idiosyncrasies of codecs e.g. - - For messagepack, configure how ambiguities in handling raw bytes are resolved - - For messagepack, provide rpc server/client codec to support - msgpack-rpc protocol defined at: - https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md - -## Extension Support - -Users can register a function to handle the encoding or decoding of -their custom types. - -There are no restrictions on what the custom type can be. Some examples: - - type BisSet []int - type BitSet64 uint64 - type UUID string - type MyStructWithUnexportedFields struct { a int; b bool; c []int; } - type GifImage struct { ... } - -As an illustration, MyStructWithUnexportedFields would normally be -encoded as an empty map because it has no exported fields, while UUID -would be encoded as a string. However, with extension support, you can -encode any of these however you like. - -## RPC - -RPC Client and Server Codecs are implemented, so the codecs can be used -with the standard net/rpc package. - -## Usage - -Typical usage model: - - // create and configure Handle - var ( - bh codec.BincHandle - mh codec.MsgpackHandle - ch codec.CborHandle - ) - - mh.MapType = reflect.TypeOf(map[string]interface{}(nil)) - - // configure extensions - // e.g. for msgpack, define functions and enable Time support for tag 1 - // mh.SetExt(reflect.TypeOf(time.Time{}), 1, myExt) - - // create and use decoder/encoder - var ( - r io.Reader - w io.Writer - b []byte - h = &bh // or mh to use msgpack - ) - - dec = codec.NewDecoder(r, h) - dec = codec.NewDecoderBytes(b, h) - err = dec.Decode(&v) - - enc = codec.NewEncoder(w, h) - enc = codec.NewEncoderBytes(&b, h) - err = enc.Encode(v) - - //RPC Server - go func() { - for { - conn, err := listener.Accept() - rpcCodec := codec.GoRpc.ServerCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h) - rpc.ServeCodec(rpcCodec) - } - }() - - //RPC Communication (client side) - conn, err = net.Dial("tcp", "localhost:5555") - rpcCodec := codec.GoRpc.ClientCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h) - client := rpc.NewClientWithCodec(rpcCodec) - -## Running Tests - -To run tests, use the following: - - go test - -To run the full suite of tests, use the following: - - go test -tags alltests -run Suite - -You can run the tag 'safe' to run tests or build in safe mode. e.g. - - go test -tags safe -run Json - go test -tags "alltests safe" -run Suite - -## Running Benchmarks - -Please see http://github.com/ugorji/go-codec-bench . - diff --git a/vendor/github.com/ugorji/go/codec/cbor_test.go b/vendor/github.com/ugorji/go/codec/cbor_test.go deleted file mode 100644 index 205dffa7d1..0000000000 --- a/vendor/github.com/ugorji/go/codec/cbor_test.go +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bufio" - "bytes" - "encoding/hex" - "math" - "os" - "regexp" - "strings" - "testing" -) - -func TestCborIndefiniteLength(t *testing.T) { - oldMapType := testCborH.MapType - defer func() { - testCborH.MapType = oldMapType - }() - testCborH.MapType = testMapStrIntfTyp - // var ( - // M1 map[string][]byte - // M2 map[uint64]bool - // L1 []interface{} - // S1 []string - // B1 []byte - // ) - var v, vv interface{} - // define it (v), encode it using indefinite lengths, decode it (vv), compare v to vv - v = map[string]interface{}{ - "one-byte-key": []byte{1, 2, 3, 4, 5, 6}, - "two-string-key": "two-value", - "three-list-key": []interface{}{true, false, uint64(1), int64(-1)}, - } - var buf bytes.Buffer - // buf.Reset() - e := NewEncoder(&buf, testCborH) - buf.WriteByte(cborBdIndefiniteMap) - //---- - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode("one-") - e.MustEncode("byte-") - e.MustEncode("key") - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdIndefiniteBytes) - e.MustEncode([]byte{1, 2, 3}) - e.MustEncode([]byte{4, 5, 6}) - buf.WriteByte(cborBdBreak) - - //---- - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode("two-") - e.MustEncode("string-") - e.MustEncode("key") - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode([]byte("two-")) // encode as bytes, to check robustness of code - e.MustEncode([]byte("value")) - buf.WriteByte(cborBdBreak) - - //---- - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode("three-") - e.MustEncode("list-") - e.MustEncode("key") - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdIndefiniteArray) - e.MustEncode(true) - e.MustEncode(false) - e.MustEncode(uint64(1)) - e.MustEncode(int64(-1)) - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdBreak) // close map - - NewDecoderBytes(buf.Bytes(), testCborH).MustDecode(&vv) - if err := deepEqual(v, vv); err != nil { - logT(t, "-------- Before and After marshal do not match: Error: %v", err) - logT(t, " ....... GOLDEN: (%T) %#v", v, v) - logT(t, " ....... DECODED: (%T) %#v", vv, vv) - failT(t) - } -} - -type testCborGolden struct { - Base64 string `codec:"cbor"` - Hex string `codec:"hex"` - Roundtrip bool `codec:"roundtrip"` - Decoded interface{} `codec:"decoded"` - Diagnostic string `codec:"diagnostic"` - Skip bool `codec:"skip"` -} - -// Some tests are skipped because they include numbers outside the range of int64/uint64 -func doTestCborGoldens(t *testing.T) { - oldMapType := testCborH.MapType - defer func() { - testCborH.MapType = oldMapType - }() - testCborH.MapType = testMapStrIntfTyp - // decode test-cbor-goldens.json into a list of []*testCborGolden - // for each one, - // - decode hex into []byte bs - // - decode bs into interface{} v - // - compare both using deepequal - // - for any miss, record it - var gs []*testCborGolden - f, err := os.Open("test-cbor-goldens.json") - if err != nil { - logT(t, "error opening test-cbor-goldens.json: %v", err) - failT(t) - } - defer f.Close() - jh := new(JsonHandle) - jh.MapType = testMapStrIntfTyp - // d := NewDecoder(f, jh) - d := NewDecoder(bufio.NewReader(f), jh) - // err = d.Decode(&gs) - d.MustDecode(&gs) - if err != nil { - logT(t, "error json decoding test-cbor-goldens.json: %v", err) - failT(t) - } - - tagregex := regexp.MustCompile(`[\d]+\(.+?\)`) - hexregex := regexp.MustCompile(`h'([0-9a-fA-F]*)'`) - for i, g := range gs { - // fmt.Printf("%v, skip: %v, isTag: %v, %s\n", i, g.Skip, tagregex.MatchString(g.Diagnostic), g.Diagnostic) - // skip tags or simple or those with prefix, as we can't verify them. - if g.Skip || strings.HasPrefix(g.Diagnostic, "simple(") || tagregex.MatchString(g.Diagnostic) { - // fmt.Printf("%v: skipped\n", i) - logT(t, "[%v] skipping because skip=true OR unsupported simple value or Tag Value", i) - continue - } - // println("++++++++++++", i, "g.Diagnostic", g.Diagnostic) - if hexregex.MatchString(g.Diagnostic) { - // println(i, "g.Diagnostic matched hex") - if s2 := g.Diagnostic[2 : len(g.Diagnostic)-1]; s2 == "" { - g.Decoded = zeroByteSlice - } else if bs2, err2 := hex.DecodeString(s2); err2 == nil { - g.Decoded = bs2 - } - // fmt.Printf("%v: hex: %v\n", i, g.Decoded) - } - bs, err := hex.DecodeString(g.Hex) - if err != nil { - logT(t, "[%v] error hex decoding %s [%v]: %v", i, g.Hex, err) - failT(t) - } - var v interface{} - NewDecoderBytes(bs, testCborH).MustDecode(&v) - if _, ok := v.(RawExt); ok { - continue - } - // check the diagnostics to compare - switch g.Diagnostic { - case "Infinity": - b := math.IsInf(v.(float64), 1) - testCborError(t, i, math.Inf(1), v, nil, &b) - case "-Infinity": - b := math.IsInf(v.(float64), -1) - testCborError(t, i, math.Inf(-1), v, nil, &b) - case "NaN": - // println(i, "checking NaN") - b := math.IsNaN(v.(float64)) - testCborError(t, i, math.NaN(), v, nil, &b) - case "undefined": - b := v == nil - testCborError(t, i, nil, v, nil, &b) - default: - v0 := g.Decoded - // testCborCoerceJsonNumber(reflect.ValueOf(&v0)) - testCborError(t, i, v0, v, deepEqual(v0, v), nil) - } - } -} - -func testCborError(t *testing.T, i int, v0, v1 interface{}, err error, equal *bool) { - if err == nil && equal == nil { - // fmt.Printf("%v testCborError passed (err and equal nil)\n", i) - return - } - if err != nil { - logT(t, "[%v] deepEqual error: %v", i, err) - logT(t, " ....... GOLDEN: (%T) %#v", v0, v0) - logT(t, " ....... DECODED: (%T) %#v", v1, v1) - failT(t) - } - if equal != nil && !*equal { - logT(t, "[%v] values not equal", i) - logT(t, " ....... GOLDEN: (%T) %#v", v0, v0) - logT(t, " ....... DECODED: (%T) %#v", v1, v1) - failT(t) - } - // fmt.Printf("%v testCborError passed (checks passed)\n", i) -} - -func TestCborGoldens(t *testing.T) { - doTestCborGoldens(t) -} diff --git a/vendor/github.com/ugorji/go/codec/codec_test.go b/vendor/github.com/ugorji/go/codec/codec_test.go deleted file mode 100644 index eb8830ba19..0000000000 --- a/vendor/github.com/ugorji/go/codec/codec_test.go +++ /dev/null @@ -1,1767 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// Test works by using a slice of interfaces. -// It can test for encoding/decoding into/from a nil interface{} -// or passing the object to encode/decode into. -// -// There are basically 2 main tests here. -// First test internally encodes and decodes things and verifies that -// the artifact was as expected. -// Second test will use python msgpack to create a bunch of golden files, -// read those files, and compare them to what it should be. It then -// writes those files back out and compares the byte streams. -// -// Taken together, the tests are pretty extensive. -// -// The following manual tests must be done: -// - TestCodecUnderlyingType - -import ( - "bytes" - "encoding/gob" - "fmt" - "io/ioutil" - "math" - "math/rand" - "net" - "net/rpc" - "os" - "os/exec" - "path/filepath" - "reflect" - "runtime" - "strconv" - "strings" - "sync/atomic" - "testing" - "time" -) - -func init() { - testPreInitFns = append(testPreInitFns, testInit) -} - -// make this a mapbyslice -type testMbsT []interface{} - -func (_ testMbsT) MapBySlice() {} - -type testVerifyArg int - -const ( - testVerifyMapTypeSame testVerifyArg = iota - testVerifyMapTypeStrIntf - testVerifyMapTypeIntfIntf - // testVerifySliceIntf - testVerifyForPython -) - -const testSkipRPCTests = false - -var ( - testTableNumPrimitives int - testTableIdxTime int - testTableNumMaps int -) - -var ( - skipVerifyVal interface{} = &(struct{}{}) - - testMapStrIntfTyp = reflect.TypeOf(map[string]interface{}(nil)) - - // For Go Time, do not use a descriptive timezone. - // It's unnecessary, and makes it harder to do a reflect.DeepEqual. - // The Offset already tells what the offset should be, if not on UTC and unknown zone name. - timeLoc = time.FixedZone("", -8*60*60) // UTC-08:00 //time.UTC-8 - timeToCompare1 = time.Date(2012, 2, 2, 2, 2, 2, 2000, timeLoc).UTC() - timeToCompare2 = time.Date(1900, 2, 2, 2, 2, 2, 2000, timeLoc).UTC() - timeToCompare3 = time.Unix(0, 270).UTC() // use value that must be encoded as uint64 for nanoseconds (for cbor/msgpack comparison) - //timeToCompare4 = time.Time{}.UTC() // does not work well with simple cbor time encoding (overflow) - timeToCompare4 = time.Unix(-2013855848, 4223).UTC() - - table []interface{} // main items we encode - tableVerify []interface{} // we verify encoded things against this after decode - tableTestNilVerify []interface{} // for nil interface, use this to verify (rules are different) - tablePythonVerify []interface{} // for verifying for python, since Python sometimes - // will encode a float32 as float64, or large int as uint - testRpcInt = new(TestRpcInt) -) - -func testByteBuf(in []byte) *bytes.Buffer { - return bytes.NewBuffer(in) -} - -type TestABC struct { - A, B, C string -} - -func (x *TestABC) MarshalBinary() ([]byte, error) { - return []byte(fmt.Sprintf("%s %s %s", x.A, x.B, x.C)), nil -} -func (x *TestABC) MarshalText() ([]byte, error) { - return []byte(fmt.Sprintf("%s %s %s", x.A, x.B, x.C)), nil -} -func (x *TestABC) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf(`"%s %s %s"`, x.A, x.B, x.C)), nil -} - -func (x *TestABC) UnmarshalBinary(data []byte) (err error) { - ss := strings.Split(string(data), " ") - x.A, x.B, x.C = ss[0], ss[1], ss[2] - return -} -func (x *TestABC) UnmarshalText(data []byte) (err error) { - return x.UnmarshalBinary(data) -} -func (x *TestABC) UnmarshalJSON(data []byte) (err error) { - return x.UnmarshalBinary(data[1 : len(data)-1]) -} - -type TestABC2 struct { - A, B, C string -} - -func (x TestABC2) MarshalText() ([]byte, error) { - return []byte(fmt.Sprintf("%s %s %s", x.A, x.B, x.C)), nil -} -func (x *TestABC2) UnmarshalText(data []byte) (err error) { - ss := strings.Split(string(data), " ") - x.A, x.B, x.C = ss[0], ss[1], ss[2] - return - // _, err = fmt.Sscanf(string(data), "%s %s %s", &x.A, &x.B, &x.C) -} - -type TestSimplish struct { - Ii int - Ss string - Ar [2]*TestSimplish - Sl []*TestSimplish - Mm map[string]*TestSimplish -} - -type TestRpcABC struct { - A, B, C string -} - -type TestRpcInt struct { - i int -} - -func (r *TestRpcInt) Update(n int, res *int) error { r.i = n; *res = r.i; return nil } -func (r *TestRpcInt) Square(ignore int, res *int) error { *res = r.i * r.i; return nil } -func (r *TestRpcInt) Mult(n int, res *int) error { *res = r.i * n; return nil } -func (r *TestRpcInt) EchoStruct(arg TestRpcABC, res *string) error { - *res = fmt.Sprintf("%#v", arg) - return nil -} -func (r *TestRpcInt) Echo123(args []string, res *string) error { - *res = fmt.Sprintf("%#v", args) - return nil -} - -type TestRawValue struct { - R Raw - I int -} - -type testUnixNanoTimeExt struct { - // keep timestamp here, so that do not incur interface-conversion costs - ts int64 -} - -// func (x *testUnixNanoTimeExt) WriteExt(interface{}) []byte { panic("unsupported") } -// func (x *testUnixNanoTimeExt) ReadExt(interface{}, []byte) { panic("unsupported") } -func (x *testUnixNanoTimeExt) ConvertExt(v interface{}) interface{} { - switch v2 := v.(type) { - case time.Time: - x.ts = v2.UTC().UnixNano() - case *time.Time: - x.ts = v2.UTC().UnixNano() - default: - panic(fmt.Sprintf("unsupported format for time conversion: expecting time.Time; got %T", v)) - } - return &x.ts -} -func (x *testUnixNanoTimeExt) UpdateExt(dest interface{}, v interface{}) { - // fmt.Printf("testUnixNanoTimeExt.UpdateExt: v: %v\n", v) - tt := dest.(*time.Time) - switch v2 := v.(type) { - case int64: - *tt = time.Unix(0, v2).UTC() - case *int64: - *tt = time.Unix(0, *v2).UTC() - case uint64: - *tt = time.Unix(0, int64(v2)).UTC() - case *uint64: - *tt = time.Unix(0, int64(*v2)).UTC() - //case float64: - //case string: - default: - panic(fmt.Sprintf("unsupported format for time conversion: expecting int64/uint64; got %T", v)) - } - // fmt.Printf("testUnixNanoTimeExt.UpdateExt: v: %v, tt: %#v\n", v, tt) -} - -func testVerifyVal(v interface{}, arg testVerifyArg) (v2 interface{}) { - //for python msgpack, - // - all positive integers are unsigned 64-bit ints - // - all floats are float64 - switch iv := v.(type) { - case int8: - if iv >= 0 { - v2 = uint64(iv) - } else { - v2 = int64(iv) - } - case int16: - if iv >= 0 { - v2 = uint64(iv) - } else { - v2 = int64(iv) - } - case int32: - if iv >= 0 { - v2 = uint64(iv) - } else { - v2 = int64(iv) - } - case int64: - if iv >= 0 { - v2 = uint64(iv) - } else { - v2 = int64(iv) - } - case uint8: - v2 = uint64(iv) - case uint16: - v2 = uint64(iv) - case uint32: - v2 = uint64(iv) - case uint64: - v2 = uint64(iv) - case float32: - v2 = float64(iv) - case float64: - v2 = float64(iv) - case []interface{}: - m2 := make([]interface{}, len(iv)) - for j, vj := range iv { - m2[j] = testVerifyVal(vj, arg) - } - v2 = m2 - case testMbsT: - m2 := make([]interface{}, len(iv)) - for j, vj := range iv { - m2[j] = testVerifyVal(vj, arg) - } - v2 = testMbsT(m2) - case map[string]bool: - switch arg { - case testVerifyMapTypeSame: - m2 := make(map[string]bool) - for kj, kv := range iv { - m2[kj] = kv - } - v2 = m2 - case testVerifyMapTypeStrIntf, testVerifyForPython: - m2 := make(map[string]interface{}) - for kj, kv := range iv { - m2[kj] = kv - } - v2 = m2 - case testVerifyMapTypeIntfIntf: - m2 := make(map[interface{}]interface{}) - for kj, kv := range iv { - m2[kj] = kv - } - v2 = m2 - } - case map[string]interface{}: - switch arg { - case testVerifyMapTypeSame: - m2 := make(map[string]interface{}) - for kj, kv := range iv { - m2[kj] = testVerifyVal(kv, arg) - } - v2 = m2 - case testVerifyMapTypeStrIntf, testVerifyForPython: - m2 := make(map[string]interface{}) - for kj, kv := range iv { - m2[kj] = testVerifyVal(kv, arg) - } - v2 = m2 - case testVerifyMapTypeIntfIntf: - m2 := make(map[interface{}]interface{}) - for kj, kv := range iv { - m2[kj] = testVerifyVal(kv, arg) - } - v2 = m2 - } - case map[interface{}]interface{}: - m2 := make(map[interface{}]interface{}) - for kj, kv := range iv { - m2[testVerifyVal(kj, arg)] = testVerifyVal(kv, arg) - } - v2 = m2 - case time.Time: - switch arg { - case testVerifyForPython: - if iv2 := iv.UnixNano(); iv2 >= 0 { - v2 = uint64(iv2) - } else { - v2 = int64(iv2) - } - default: - v2 = v - } - default: - v2 = v - } - return -} - -func testInit() { - gob.Register(new(TestStruc)) - if testInitDebug { - ts0 := newTestStruc(2, false, !testSkipIntf, false) - fmt.Printf("====> depth: %v, ts: %#v\n", 2, ts0) - } - - for _, v := range testHandles { - bh := v.getBasicHandle() - bh.InternString = testInternStr - bh.Canonical = testCanonical - bh.CheckCircularRef = testCheckCircRef - bh.StructToArray = testStructToArray - bh.MaxInitLen = testMaxInitLen - // mostly doing this for binc - if testWriteNoSymbols { - bh.AsSymbols = AsSymbolNone - } else { - bh.AsSymbols = AsSymbolAll - } - } - - testJsonH.Indent = int8(testJsonIndent) - testJsonH.HTMLCharsAsIs = testJsonHTMLCharsAsIs - testJsonH.PreferFloat = testJsonPreferFloat - - testMsgpackH.RawToString = true - - // testMsgpackH.AddExt(byteSliceTyp, 0, testMsgpackH.BinaryEncodeExt, testMsgpackH.BinaryDecodeExt) - // testMsgpackH.AddExt(timeTyp, 1, testMsgpackH.TimeEncodeExt, testMsgpackH.TimeDecodeExt) - - // add extensions for msgpack, simple for time.Time, so we can encode/decode same way. - // use different flavors of XXXExt calls, including deprecated ones. - // NOTE: - // DO NOT set extensions for JsonH, so we can test json(M|Unm)arshal support. - var ( - timeExtEncFn = func(rv reflect.Value) (bs []byte, err error) { - defer panicToErr(&err) - bs = timeExt{}.WriteExt(rv.Interface()) - return - } - timeExtDecFn = func(rv reflect.Value, bs []byte) (err error) { - defer panicToErr(&err) - timeExt{}.ReadExt(rv.Interface(), bs) - return - } - ) - testSimpleH.AddExt(timeTyp, 1, timeExtEncFn, timeExtDecFn) - - testMsgpackH.SetBytesExt(timeTyp, 1, timeExt{}) - testCborH.SetInterfaceExt(timeTyp, 1, &testUnixNanoTimeExt{}) - // testJsonH.SetInterfaceExt(timeTyp, 1, &testUnixNanoTimeExt{}) - - // primitives MUST be an even number, so it can be used as a mapBySlice also. - primitives := []interface{}{ - int8(-8), - int16(-1616), - int32(-32323232), - int64(-6464646464646464), - uint8(192), - uint16(1616), - uint32(32323232), - uint64(6464646464646464), - byte(192), - float32(-3232.0), - float64(-6464646464.0), - float32(3232.0), - float64(6464.0), - float64(6464646464.0), - false, - true, - "null", - nil, - "some&day>some lp { - av[i] = skipVerifyVal - continue - } - av[i] = testVerifyVal(v, testVerifyMapTypeStrIntf) - } - - av = tablePythonVerify - for i, v := range table { - if i == testTableNumPrimitives+1 || i > lp { // testTableNumPrimitives+1 is the mapBySlice - av[i] = skipVerifyVal - continue - } - av[i] = testVerifyVal(v, testVerifyForPython) - } - - // only do the python verify up to the maps, skipping the last 2 maps. - tablePythonVerify = tablePythonVerify[:testTableNumPrimitives+2+testTableNumMaps-2] -} - -func testUnmarshal(v interface{}, data []byte, h Handle) (err error) { - return testCodecDecode(data, v, h) -} - -func testMarshal(v interface{}, h Handle) (bs []byte, err error) { - return testCodecEncode(v, nil, testByteBuf, h) -} - -func testMarshalErr(v interface{}, h Handle, t *testing.T, name string) (bs []byte, err error) { - if bs, err = testMarshal(v, h); err != nil { - logT(t, "Error encoding %s: %v, Err: %v", name, v, err) - failT(t) - } - return -} - -func testUnmarshalErr(v interface{}, data []byte, h Handle, t *testing.T, name string) (err error) { - if err = testUnmarshal(v, data, h); err != nil { - logT(t, "Error Decoding into %s: %v, Err: %v", name, v, err) - failT(t) - } - return -} - -func testDeepEqualErr(v1, v2 interface{}, t *testing.T, name string) (err error) { - if err = deepEqual(v1, v2); err == nil { - logT(t, "%s: values equal", name) - } else { - logT(t, "%s: values not equal: %v. 1: %v, 2: %v", name, err, v1, v2) - failT(t) - } - return -} - -// doTestCodecTableOne allows us test for different variations based on arguments passed. -func doTestCodecTableOne(t *testing.T, testNil bool, h Handle, - vs []interface{}, vsVerify []interface{}) { - //if testNil, then just test for when a pointer to a nil interface{} is passed. It should work. - //Current setup allows us test (at least manually) the nil interface or typed interface. - logT(t, "================ TestNil: %v ================\n", testNil) - for i, v0 := range vs { - logT(t, "..............................................") - logT(t, " Testing: #%d:, %T, %#v\n", i, v0, v0) - b0, err := testMarshalErr(v0, h, t, "v0") - if err != nil { - continue - } - if h.isBinary() { - logT(t, " Encoded bytes: len: %v, %v\n", len(b0), b0) - } else { - logT(t, " Encoded string: len: %v, %v\n", len(string(b0)), string(b0)) - // println("########### encoded string: " + string(b0)) - } - var v1 interface{} - - if testNil { - err = testUnmarshal(&v1, b0, h) - } else { - if v0 != nil { - v0rt := reflect.TypeOf(v0) // ptr - rv1 := reflect.New(v0rt) - err = testUnmarshal(rv1.Interface(), b0, h) - v1 = rv1.Elem().Interface() - // v1 = reflect.Indirect(reflect.ValueOf(v1)).Interface() - } - } - - logT(t, " v1 returned: %T, %#v", v1, v1) - // if v1 != nil { - // logT(t, " v1 returned: %T, %#v", v1, v1) - // //we always indirect, because ptr to typed value may be passed (if not testNil) - // v1 = reflect.Indirect(reflect.ValueOf(v1)).Interface() - // } - if err != nil { - logT(t, "-------- Error: %v. Partial return: %v", err, v1) - failT(t) - continue - } - v0check := vsVerify[i] - if v0check == skipVerifyVal { - logT(t, " Nil Check skipped: Decoded: %T, %#v\n", v1, v1) - continue - } - - if err = deepEqual(v0check, v1); err == nil { - logT(t, "++++++++ Before and After marshal matched\n") - } else { - // logT(t, "-------- Before and After marshal do not match: Error: %v"+ - // " ====> GOLDEN: (%T) %#v, DECODED: (%T) %#v\n", err, v0check, v0check, v1, v1) - logT(t, "-------- Before and After marshal do not match: Error: %v", err) - logT(t, " ....... GOLDEN: (%T) %#v", v0check, v0check) - logT(t, " ....... DECODED: (%T) %#v", v1, v1) - failT(t) - } - } -} - -func testCodecTableOne(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // func TestMsgpackAllExperimental(t *testing.T) { - // dopts := testDecOpts(nil, nil, false, true, true), - - numPrim, numMap, idxTime, idxMap := testTableNumPrimitives, testTableNumMaps, testTableIdxTime, testTableNumPrimitives+2 - - //println("#################") - switch v := h.(type) { - case *MsgpackHandle: - var oldWriteExt, oldRawToString bool - oldWriteExt, v.WriteExt = v.WriteExt, true - oldRawToString, v.RawToString = v.RawToString, true - doTestCodecTableOne(t, false, h, table, tableVerify) - v.WriteExt, v.RawToString = oldWriteExt, oldRawToString - case *JsonHandle: - //skip []interface{} containing time.Time, as it encodes as a number, but cannot decode back to time.Time. - //As there is no real support for extension tags in json, this must be skipped. - doTestCodecTableOne(t, false, h, table[:numPrim], tableVerify[:numPrim]) - doTestCodecTableOne(t, false, h, table[idxMap:], tableVerify[idxMap:]) - default: - doTestCodecTableOne(t, false, h, table, tableVerify) - } - // func TestMsgpackAll(t *testing.T) { - - // //skip []interface{} containing time.Time - // doTestCodecTableOne(t, false, h, table[:numPrim], tableVerify[:numPrim]) - // doTestCodecTableOne(t, false, h, table[numPrim+1:], tableVerify[numPrim+1:]) - // func TestMsgpackNilStringMap(t *testing.T) { - var oldMapType reflect.Type - v := h.getBasicHandle() - - oldMapType, v.MapType = v.MapType, testMapStrIntfTyp - - //skip time.Time, []interface{} containing time.Time, last map, and newStruc - doTestCodecTableOne(t, true, h, table[:idxTime], tableTestNilVerify[:idxTime]) - doTestCodecTableOne(t, true, h, table[idxMap:idxMap+numMap-1], tableTestNilVerify[idxMap:idxMap+numMap-1]) - - v.MapType = oldMapType - - // func TestMsgpackNilIntf(t *testing.T) { - - //do last map and newStruc - idx2 := idxMap + numMap - 1 - doTestCodecTableOne(t, true, h, table[idx2:], tableTestNilVerify[idx2:]) - //TODO? What is this one? - //doTestCodecTableOne(t, true, h, table[17:18], tableTestNilVerify[17:18]) -} - -func testCodecMiscOne(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - b, err := testMarshalErr(32, h, t, "32") - // Cannot do this nil one, because faster type assertion decoding will panic - // var i *int32 - // if err = testUnmarshal(b, i, nil); err == nil { - // logT(t, "------- Expecting error because we cannot unmarshal to int32 nil ptr") - // failT(t) - // } - var i2 int32 = 0 - err = testUnmarshalErr(&i2, b, h, t, "int32-ptr") - if i2 != int32(32) { - logT(t, "------- didn't unmarshal to 32: Received: %d", i2) - failT(t) - } - - // func TestMsgpackDecodePtr(t *testing.T) { - ts := newTestStruc(0, false, !testSkipIntf, false) - b, err = testMarshalErr(ts, h, t, "pointer-to-struct") - if len(b) < 40 { - logT(t, "------- Size must be > 40. Size: %d", len(b)) - failT(t) - } - if h.isBinary() { - logT(t, "------- b: %v", b) - } else { - logT(t, "------- b: %s", b) - } - ts2 := new(TestStruc) - err = testUnmarshalErr(ts2, b, h, t, "pointer-to-struct") - if ts2.I64 != math.MaxInt64*2/3 { - logT(t, "------- Unmarshal wrong. Expect I64 = 64. Got: %v", ts2.I64) - failT(t) - } - - // func TestMsgpackIntfDecode(t *testing.T) { - m := map[string]int{"A": 2, "B": 3} - p := []interface{}{m} - bs, err := testMarshalErr(p, h, t, "p") - - m2 := map[string]int{} - p2 := []interface{}{m2} - err = testUnmarshalErr(&p2, bs, h, t, "&p2") - - if m2["A"] != 2 || m2["B"] != 3 { - logT(t, "m2 not as expected: expecting: %v, got: %v", m, m2) - failT(t) - } - // log("m: %v, m2: %v, p: %v, p2: %v", m, m2, p, p2) - checkEqualT(t, p, p2, "p=p2") - checkEqualT(t, m, m2, "m=m2") - if err = deepEqual(p, p2); err == nil { - logT(t, "p and p2 match") - } else { - logT(t, "Not Equal: %v. p: %v, p2: %v", err, p, p2) - failT(t) - } - if err = deepEqual(m, m2); err == nil { - logT(t, "m and m2 match") - } else { - logT(t, "Not Equal: %v. m: %v, m2: %v", err, m, m2) - failT(t) - } - - // func TestMsgpackDecodeStructSubset(t *testing.T) { - // test that we can decode a subset of the stream - mm := map[string]interface{}{"A": 5, "B": 99, "C": 333} - bs, err = testMarshalErr(mm, h, t, "mm") - type ttt struct { - A uint8 - C int32 - } - var t2 ttt - testUnmarshalErr(&t2, bs, h, t, "t2") - t3 := ttt{5, 333} - checkEqualT(t, t2, t3, "t2=t3") - - // println(">>>>>") - // test simple arrays, non-addressable arrays, slices - type tarr struct { - A int64 - B [3]int64 - C []byte - D [3]byte - } - var tarr0 = tarr{1, [3]int64{2, 3, 4}, []byte{4, 5, 6}, [3]byte{7, 8, 9}} - // test both pointer and non-pointer (value) - for _, tarr1 := range []interface{}{tarr0, &tarr0} { - bs, err = testMarshalErr(tarr1, h, t, "tarr1") - if err != nil { - logT(t, "Error marshalling: %v", err) - failT(t) - } - if _, ok := h.(*JsonHandle); ok { - logT(t, "Marshal as: %s", bs) - } - var tarr2 tarr - testUnmarshalErr(&tarr2, bs, h, t, "tarr2") - checkEqualT(t, tarr0, tarr2, "tarr0=tarr2") - // fmt.Printf(">>>> err: %v. tarr1: %v, tarr2: %v\n", err, tarr0, tarr2) - } - - // test byte array, even if empty (msgpack only) - if h == testMsgpackH { - type ystruct struct { - Anarray []byte - } - var ya = ystruct{} - testUnmarshalErr(&ya, []byte{0x91, 0x90}, h, t, "ya") - } -} - -func testCodecEmbeddedPointer(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - type Z int - type A struct { - AnInt int - } - type B struct { - *Z - *A - MoreInt int - } - var z Z = 4 - x1 := &B{&z, &A{5}, 6} - bs, err := testMarshalErr(x1, h, t, "x1") - // fmt.Printf("buf: len(%v): %x\n", buf.Len(), buf.Bytes()) - var x2 = new(B) - err = testUnmarshalErr(x2, bs, h, t, "x2") - err = checkEqualT(t, x1, x2, "x1=x2") - _ = err -} - -func testCodecUnderlyingType(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // Manual Test. - // Run by hand, with accompanying print statements in fast-path.go - // to ensure that the fast functions are called. - type T1 map[string]string - v := T1{"1": "1s", "2": "2s"} - var bs []byte - var err error - NewEncoderBytes(&bs, h).MustEncode(v) - if err != nil { - logT(t, "Error during encode: %v", err) - failT(t) - } - var v2 T1 - NewDecoderBytes(bs, h).MustDecode(&v2) - if err != nil { - logT(t, "Error during decode: %v", err) - failT(t) - } -} - -func testCodecChan(t *testing.T, h Handle) { - // - send a slice []*int64 (sl1) into an chan (ch1) with cap > len(s1) - // - encode ch1 as a stream array - // - decode a chan (ch2), with cap > len(s1) from the stream array - // - receive from ch2 into slice sl2 - // - compare sl1 and sl2 - // - do this for codecs: json, cbor (covers all types) - sl1 := make([]*int64, 4) - for i := range sl1 { - var j int64 = int64(i) - sl1[i] = &j - } - ch1 := make(chan *int64, 4) - for _, j := range sl1 { - ch1 <- j - } - var bs []byte - NewEncoderBytes(&bs, h).MustEncode(ch1) - // if !h.isBinary() { - // fmt.Printf("before: len(ch1): %v, bs: %s\n", len(ch1), bs) - // } - // var ch2 chan *int64 // this will block if json, etc. - ch2 := make(chan *int64, 8) - NewDecoderBytes(bs, h).MustDecode(&ch2) - // logT(t, "Len(ch2): %v", len(ch2)) - // fmt.Printf("after: len(ch2): %v, ch2: %v\n", len(ch2), ch2) - close(ch2) - var sl2 []*int64 - for j := range ch2 { - sl2 = append(sl2, j) - } - if err := deepEqual(sl1, sl2); err != nil { - logT(t, "Not Match: %v; len: %v, %v", err, len(sl1), len(sl2)) - failT(t) - } -} - -func testCodecRpcOne(t *testing.T, rr Rpc, h Handle, doRequest bool, exitSleepMs time.Duration, -) (port int) { - testOnce.Do(testInitAll) - if testSkipRPCTests { - return - } - // rpc needs EOF, which is sent via a panic, and so must be recovered. - if !recoverPanicToErr { - logT(t, "EXPECTED. set recoverPanicToErr=true, since rpc needs EOF") - failT(t) - } - srv := rpc.NewServer() - srv.Register(testRpcInt) - ln, err := net.Listen("tcp", "127.0.0.1:0") - // log("listener: %v", ln.Addr()) - checkErrT(t, err) - port = (ln.Addr().(*net.TCPAddr)).Port - // var opts *DecoderOptions - // opts := testDecOpts - // opts.MapType = mapStrIntfTyp - // opts.RawToString = false - serverExitChan := make(chan bool, 1) - var serverExitFlag uint64 = 0 - serverFn := func() { - for { - conn1, err1 := ln.Accept() - // if err1 != nil { - // //fmt.Printf("accept err1: %v\n", err1) - // continue - // } - if atomic.LoadUint64(&serverExitFlag) == 1 { - serverExitChan <- true - conn1.Close() - return // exit serverFn goroutine - } - if err1 == nil { - var sc rpc.ServerCodec = rr.ServerCodec(conn1, h) - srv.ServeCodec(sc) - } - } - } - - clientFn := func(cc rpc.ClientCodec) { - cl := rpc.NewClientWithCodec(cc) - defer cl.Close() - // defer func() { println("##### client closing"); cl.Close() }() - var up, sq, mult int - var rstr string - // log("Calling client") - checkErrT(t, cl.Call("TestRpcInt.Update", 5, &up)) - // log("Called TestRpcInt.Update") - checkEqualT(t, testRpcInt.i, 5, "testRpcInt.i=5") - checkEqualT(t, up, 5, "up=5") - checkErrT(t, cl.Call("TestRpcInt.Square", 1, &sq)) - checkEqualT(t, sq, 25, "sq=25") - checkErrT(t, cl.Call("TestRpcInt.Mult", 20, &mult)) - checkEqualT(t, mult, 100, "mult=100") - checkErrT(t, cl.Call("TestRpcInt.EchoStruct", TestRpcABC{"Aa", "Bb", "Cc"}, &rstr)) - checkEqualT(t, rstr, fmt.Sprintf("%#v", TestRpcABC{"Aa", "Bb", "Cc"}), "rstr=") - checkErrT(t, cl.Call("TestRpcInt.Echo123", []string{"A1", "B2", "C3"}, &rstr)) - checkEqualT(t, rstr, fmt.Sprintf("%#v", []string{"A1", "B2", "C3"}), "rstr=") - } - - connFn := func() (bs net.Conn) { - // log("calling f1") - bs, err2 := net.Dial(ln.Addr().Network(), ln.Addr().String()) - //fmt.Printf("f1. bs: %v, err2: %v\n", bs, err2) - checkErrT(t, err2) - return - } - - exitFn := func() { - atomic.StoreUint64(&serverExitFlag, 1) - bs := connFn() - <-serverExitChan - bs.Close() - // serverExitChan <- true - } - - go serverFn() - runtime.Gosched() - //time.Sleep(100 * time.Millisecond) - if exitSleepMs == 0 { - defer ln.Close() - defer exitFn() - } - if doRequest { - bs := connFn() - cc := rr.ClientCodec(bs, h) - clientFn(cc) - } - if exitSleepMs != 0 { - go func() { - defer ln.Close() - time.Sleep(exitSleepMs) - exitFn() - }() - } - return -} - -func doTestMapEncodeForCanonical(t *testing.T, name string, h Handle) { - v1 := map[string]interface{}{ - "a": 1, - "b": "hello", - "c": map[string]interface{}{ - "c/a": 1, - "c/b": "world", - "c/c": []int{1, 2, 3, 4}, - "c/d": map[string]interface{}{ - "c/d/a": "fdisajfoidsajfopdjsaopfjdsapofda", - "c/d/b": "fdsafjdposakfodpsakfopdsakfpodsakfpodksaopfkdsopafkdopsa", - "c/d/c": "poir02 ir30qif4p03qir0pogjfpoaerfgjp ofke[padfk[ewapf kdp[afep[aw", - "c/d/d": "fdsopafkd[sa f-32qor-=4qeof -afo-erfo r-eafo 4e- o r4-qwo ag", - "c/d/e": "kfep[a sfkr0[paf[a foe-[wq ewpfao-q ro3-q ro-4qof4-qor 3-e orfkropzjbvoisdb", - "c/d/f": "", - }, - "c/e": map[int]string{ - 1: "1", - 22: "22", - 333: "333", - 4444: "4444", - 55555: "55555", - }, - "c/f": map[string]int{ - "1": 1, - "22": 22, - "333": 333, - "4444": 4444, - "55555": 55555, - }, - }, - } - var v2 map[string]interface{} - var b1, b2 []byte - - // encode v1 into b1, decode b1 into v2, encode v2 into b2, compare b1 and b2 - - bh := h.getBasicHandle() - if !bh.Canonical { - bh.Canonical = true - defer func() { bh.Canonical = false }() - } - - e1 := NewEncoderBytes(&b1, h) - e1.MustEncode(v1) - d1 := NewDecoderBytes(b1, h) - d1.MustDecode(&v2) - e2 := NewEncoderBytes(&b2, h) - e2.MustEncode(v2) - if !bytes.Equal(b1, b2) { - logT(t, "Unequal bytes: %v VS %v", b1, b2) - failT(t) - } -} - -func doTestStdEncIntf(t *testing.T, name string, h Handle) { - args := [][2]interface{}{ - {&TestABC{"A", "BB", "CCC"}, new(TestABC)}, - {&TestABC2{"AAA", "BB", "C"}, new(TestABC2)}, - } - for _, a := range args { - var b []byte - e := NewEncoderBytes(&b, h) - e.MustEncode(a[0]) - d := NewDecoderBytes(b, h) - d.MustDecode(a[1]) - if err := deepEqual(a[0], a[1]); err == nil { - logT(t, "++++ Objects match") - } else { - logT(t, "---- Objects do not match: y1: %v, err: %v", a[1], err) - failT(t) - } - } -} - -func doTestEncCircularRef(t *testing.T, name string, h Handle) { - type T1 struct { - S string - B bool - T interface{} - } - type T2 struct { - S string - T *T1 - } - type T3 struct { - S string - T *T2 - } - t1 := T1{"t1", true, nil} - t2 := T2{"t2", &t1} - t3 := T3{"t3", &t2} - t1.T = &t3 - - var bs []byte - var err error - - bh := h.getBasicHandle() - if !bh.CheckCircularRef { - bh.CheckCircularRef = true - defer func() { bh.CheckCircularRef = false }() - } - err = NewEncoderBytes(&bs, h).Encode(&t3) - if err == nil { - logT(t, "expecting error due to circular reference. found none") - failT(t) - } - if x := err.Error(); strings.Contains(x, "circular") || strings.Contains(x, "cyclic") { - logT(t, "error detected as expected: %v", x) - } else { - logT(t, "error detected was not as expected: %v", x) - failT(t) - } -} - -// TestAnonCycleT{1,2,3} types are used to test anonymous cycles. -// They are top-level, so that they can have circular references. -type ( - TestAnonCycleT1 struct { - S string - TestAnonCycleT2 - } - TestAnonCycleT2 struct { - S2 string - TestAnonCycleT3 - } - TestAnonCycleT3 struct { - *TestAnonCycleT1 - } -) - -func doTestAnonCycle(t *testing.T, name string, h Handle) { - var x TestAnonCycleT1 - x.S = "hello" - x.TestAnonCycleT2.S2 = "hello.2" - x.TestAnonCycleT2.TestAnonCycleT3.TestAnonCycleT1 = &x - - // just check that you can get typeInfo for T1 - rt := reflect.TypeOf((*TestAnonCycleT1)(nil)).Elem() - rtid := rt2id(rt) - pti := h.getBasicHandle().getTypeInfo(rtid, rt) - logT(t, "pti: %v", pti) -} - -func doTestJsonLargeInteger(t *testing.T, v interface{}, ias uint8) { - logT(t, "Running doTestJsonLargeInteger: v: %#v, ias: %c", v, ias) - oldIAS := testJsonH.IntegerAsString - defer func() { testJsonH.IntegerAsString = oldIAS }() - testJsonH.IntegerAsString = ias - - var vu uint - var vi int - var vb bool - var b []byte - e := NewEncoderBytes(&b, testJsonH) - e.MustEncode(v) - e.MustEncode(true) - d := NewDecoderBytes(b, testJsonH) - // below, we validate that the json string or number was encoded, - // then decode, and validate that the correct value was decoded. - fnStrChk := func() { - // check that output started with ", and ended with "true - if !(b[0] == '"' && string(b[len(b)-5:]) == `"true`) { - logT(t, "Expecting a JSON string, got: %s", b) - failT(t) - } - } - - switch ias { - case 'L': - switch v2 := v.(type) { - case int: - v2n := int64(v2) // done to work with 32-bit OS - if v2n > 1<<53 || (v2n < 0 && -v2n > 1<<53) { - fnStrChk() - } - case uint: - v2n := uint64(v2) // done to work with 32-bit OS - if v2n > 1<<53 { - fnStrChk() - } - } - case 'A': - fnStrChk() - default: - // check that output doesn't contain " at all - for _, i := range b { - if i == '"' { - logT(t, "Expecting a JSON Number without quotation: got: %s", b) - failT(t) - } - } - } - switch v2 := v.(type) { - case int: - d.MustDecode(&vi) - d.MustDecode(&vb) - // check that vb = true, and vi == v2 - if !(vb && vi == v2) { - logT(t, "Expecting equal values from %s: got golden: %v, decoded: %v", b, v2, vi) - failT(t) - } - case uint: - d.MustDecode(&vu) - d.MustDecode(&vb) - // check that vb = true, and vi == v2 - if !(vb && vu == v2) { - logT(t, "Expecting equal values from %s: got golden: %v, decoded: %v", b, v2, vu) - failT(t) - } - // fmt.Printf("%v: %s, decode: %d, bool: %v, equal_on_decode: %v\n", v, b, vu, vb, vu == v.(uint)) - } -} - -func doTestRawValue(t *testing.T, name string, h Handle) { - bh := h.getBasicHandle() - if !bh.Raw { - bh.Raw = true - defer func() { bh.Raw = false }() - } - - var i, i2 int - var v, v2 TestRawValue - var bs, bs2 []byte - - i = 1234 //1234567890 - v = TestRawValue{I: i} - e := NewEncoderBytes(&bs, h) - e.MustEncode(v.I) - logT(t, ">>> raw: %v\n", bs) - - v.R = Raw(bs) - e.ResetBytes(&bs2) - e.MustEncode(v) - - logT(t, ">>> bs2: %v\n", bs2) - d := NewDecoderBytes(bs2, h) - d.MustDecode(&v2) - d.ResetBytes(v2.R) - logT(t, ">>> v2.R: %v\n", ([]byte)(v2.R)) - d.MustDecode(&i2) - - logT(t, ">>> Encoded %v, decoded %v\n", i, i2) - // logT(t, "Encoded %v, decoded %v", i, i2) - if i != i2 { - logT(t, "Error: encoded %v, decoded %v", i, i2) - failT(t) - } -} - -// Comprehensive testing that generates data encoded from python handle (cbor, msgpack), -// and validates that our code can read and write it out accordingly. -// We keep this unexported here, and put actual test in ext_dep_test.go. -// This way, it can be excluded by excluding file completely. -func doTestPythonGenStreams(t *testing.T, name string, h Handle) { - logT(t, "TestPythonGenStreams-%v", name) - tmpdir, err := ioutil.TempDir("", "golang-"+name+"-test") - if err != nil { - logT(t, "-------- Unable to create temp directory\n") - failT(t) - } - defer os.RemoveAll(tmpdir) - logT(t, "tmpdir: %v", tmpdir) - cmd := exec.Command("python", "test.py", "testdata", tmpdir) - //cmd.Stdin = strings.NewReader("some input") - //cmd.Stdout = &out - var cmdout []byte - if cmdout, err = cmd.CombinedOutput(); err != nil { - logT(t, "-------- Error running test.py testdata. Err: %v", err) - logT(t, " %v", string(cmdout)) - failT(t) - } - - bh := h.getBasicHandle() - - oldMapType := bh.MapType - for i, v := range tablePythonVerify { - // if v == uint64(0) && h == testMsgpackH { - // v = int64(0) - // } - bh.MapType = oldMapType - //load up the golden file based on number - //decode it - //compare to in-mem object - //encode it again - //compare to output stream - logT(t, "..............................................") - logT(t, " Testing: #%d: %T, %#v\n", i, v, v) - var bss []byte - bss, err = ioutil.ReadFile(filepath.Join(tmpdir, strconv.Itoa(i)+"."+name+".golden")) - if err != nil { - logT(t, "-------- Error reading golden file: %d. Err: %v", i, err) - failT(t) - continue - } - bh.MapType = testMapStrIntfTyp - - var v1 interface{} - if err = testUnmarshal(&v1, bss, h); err != nil { - logT(t, "-------- Error decoding stream: %d: Err: %v", i, err) - failT(t) - continue - } - if v == skipVerifyVal { - continue - } - //no need to indirect, because we pass a nil ptr, so we already have the value - //if v1 != nil { v1 = reflect.Indirect(reflect.ValueOf(v1)).Interface() } - if err = deepEqual(v, v1); err == nil { - logT(t, "++++++++ Objects match: %T, %v", v, v) - } else { - logT(t, "-------- Objects do not match: %v. Source: %T. Decoded: %T", err, v, v1) - logT(t, "-------- GOLDEN: %#v", v) - // logT(t, "-------- DECODED: %#v <====> %#v", v1, reflect.Indirect(reflect.ValueOf(v1)).Interface()) - logT(t, "-------- DECODED: %#v <====> %#v", v1, reflect.Indirect(reflect.ValueOf(v1)).Interface()) - failT(t) - } - bsb, err := testMarshal(v1, h) - if err != nil { - logT(t, "Error encoding to stream: %d: Err: %v", i, err) - failT(t) - continue - } - if err = deepEqual(bsb, bss); err == nil { - logT(t, "++++++++ Bytes match") - } else { - logT(t, "???????? Bytes do not match. %v.", err) - xs := "--------" - if reflect.ValueOf(v).Kind() == reflect.Map { - xs = " " - logT(t, "%s It's a map. Ok that they don't match (dependent on ordering).", xs) - } else { - logT(t, "%s It's not a map. They should match.", xs) - failT(t) - } - logT(t, "%s FROM_FILE: %4d] %v", xs, len(bss), bss) - logT(t, "%s ENCODED: %4d] %v", xs, len(bsb), bsb) - } - } - bh.MapType = oldMapType -} - -// To test MsgpackSpecRpc, we test 3 scenarios: -// - Go Client to Go RPC Service (contained within TestMsgpackRpcSpec) -// - Go client to Python RPC Service (contained within doTestMsgpackRpcSpecGoClientToPythonSvc) -// - Python Client to Go RPC Service (contained within doTestMsgpackRpcSpecPythonClientToGoSvc) -// -// This allows us test the different calling conventions -// - Go Service requires only one argument -// - Python Service allows multiple arguments - -func doTestMsgpackRpcSpecGoClientToPythonSvc(t *testing.T) { - if testSkipRPCTests { - return - } - // openPorts are between 6700 and 6800 - r := rand.New(rand.NewSource(time.Now().UnixNano())) - openPort := strconv.FormatInt(6700+r.Int63n(99), 10) - // openPort := "6792" - cmd := exec.Command("python", "test.py", "rpc-server", openPort, "4") - checkErrT(t, cmd.Start()) - bs, err2 := net.Dial("tcp", ":"+openPort) - for i := 0; i < 10 && err2 != nil; i++ { - time.Sleep(50 * time.Millisecond) // time for python rpc server to start - bs, err2 = net.Dial("tcp", ":"+openPort) - } - checkErrT(t, err2) - cc := MsgpackSpecRpc.ClientCodec(bs, testMsgpackH) - cl := rpc.NewClientWithCodec(cc) - defer cl.Close() - var rstr string - checkErrT(t, cl.Call("EchoStruct", TestRpcABC{"Aa", "Bb", "Cc"}, &rstr)) - //checkEqualT(t, rstr, "{'A': 'Aa', 'B': 'Bb', 'C': 'Cc'}") - var mArgs MsgpackSpecRpcMultiArgs = []interface{}{"A1", "B2", "C3"} - checkErrT(t, cl.Call("Echo123", mArgs, &rstr)) - checkEqualT(t, rstr, "1:A1 2:B2 3:C3", "rstr=") - cmd.Process.Kill() -} - -func doTestMsgpackRpcSpecPythonClientToGoSvc(t *testing.T) { - if testSkipRPCTests { - return - } - port := testCodecRpcOne(t, MsgpackSpecRpc, testMsgpackH, false, 1*time.Second) - //time.Sleep(1000 * time.Millisecond) - cmd := exec.Command("python", "test.py", "rpc-client-go-service", strconv.Itoa(port)) - var cmdout []byte - var err error - if cmdout, err = cmd.CombinedOutput(); err != nil { - logT(t, "-------- Error running test.py rpc-client-go-service. Err: %v", err) - logT(t, " %v", string(cmdout)) - failT(t) - } - checkEqualT(t, string(cmdout), - fmt.Sprintf("%#v\n%#v\n", []string{"A1", "B2", "C3"}, TestRpcABC{"Aa", "Bb", "Cc"}), "cmdout=") -} - -func testRandomFillRV(v reflect.Value) { - fneg := func() int64 { - i := rand.Intn(1) - if i == 1 { - return 1 - } - return -1 - } - - switch v.Kind() { - case reflect.Invalid: - case reflect.Ptr: - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - testRandomFillRV(v.Elem()) - case reflect.Interface: - if v.IsNil() { - v.Set(reflect.ValueOf("nothing")) - } else { - testRandomFillRV(v.Elem()) - } - case reflect.Struct: - for i, n := 0, v.NumField(); i < n; i++ { - testRandomFillRV(v.Field(i)) - } - case reflect.Slice: - if v.IsNil() { - v.Set(reflect.MakeSlice(v.Type(), 4, 4)) - } - fallthrough - case reflect.Array: - for i, n := 0, v.Len(); i < n; i++ { - testRandomFillRV(v.Index(i)) - } - case reflect.Map: - if v.IsNil() { - v.Set(reflect.MakeMap(v.Type())) - } - if v.Len() == 0 { - kt, vt := v.Type().Key(), v.Type().Elem() - for i := 0; i < 4; i++ { - k0 := reflect.New(kt).Elem() - v0 := reflect.New(vt).Elem() - testRandomFillRV(k0) - testRandomFillRV(v0) - v.SetMapIndex(k0, v0) - } - } else { - for _, k := range v.MapKeys() { - testRandomFillRV(v.MapIndex(k)) - } - } - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - v.SetInt(fneg() * rand.Int63n(127)) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - v.SetUint(uint64(rand.Int63n(255))) - case reflect.Bool: - if fneg() == 1 { - v.SetBool(true) - } else { - v.SetBool(false) - } - case reflect.Float32, reflect.Float64: - v.SetFloat(float64(fneg()) * float64(rand.Float32())) - case reflect.String: - v.SetString(strings.Repeat(strconv.FormatInt(rand.Int63n(99), 10), rand.Intn(8))) - default: - panic(fmt.Errorf("testRandomFillRV: unsupported type: %v", v.Kind())) - } -} - -func testMammoth(t *testing.T, name string, h Handle) { - testOnce.Do(testInitAll) - var m, m2 TestMammoth - testRandomFillRV(reflect.ValueOf(&m).Elem()) - b, _ := testMarshalErr(&m, h, t, "mammoth-"+name) - testUnmarshalErr(&m2, b, h, t, "mammoth-"+name) - // fmt.Printf("m2: %v", &m2) - testDeepEqualErr(&m, &m2, t, "mammoth-"+name) -} - -// ----------------- - -func TestBincCodecsTable(t *testing.T) { - testCodecTableOne(t, testBincH) -} - -func TestBincCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testBincH) -} - -func TestBincCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testBincH) -} - -func TestBincStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, "binc", testBincH) -} - -func TestBincMammoth(t *testing.T) { - testMammoth(t, "binc", testBincH) -} - -func TestSimpleCodecsTable(t *testing.T) { - testCodecTableOne(t, testSimpleH) -} - -func TestSimpleCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testSimpleH) -} - -func TestSimpleCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testSimpleH) -} - -func TestSimpleStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, "simple", testSimpleH) -} - -func TestSimpleMammoth(t *testing.T) { - testMammoth(t, "simple", testSimpleH) -} - -func TestMsgpackCodecsTable(t *testing.T) { - testCodecTableOne(t, testMsgpackH) -} - -func TestMsgpackCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testMsgpackH) -} - -func TestMsgpackCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testMsgpackH) -} - -func TestMsgpackStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, "msgpack", testMsgpackH) -} - -func TestMsgpackMammoth(t *testing.T) { - testMammoth(t, "msgpack", testMsgpackH) -} - -func TestCborCodecsTable(t *testing.T) { - testCodecTableOne(t, testCborH) -} - -func TestCborCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testCborH) -} - -func TestCborCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testCborH) -} - -func TestCborMapEncodeForCanonical(t *testing.T) { - doTestMapEncodeForCanonical(t, "cbor", testCborH) -} - -func TestCborCodecChan(t *testing.T) { - testCodecChan(t, testCborH) -} - -func TestCborStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, "cbor", testCborH) -} - -func TestCborMammoth(t *testing.T) { - testMammoth(t, "cbor", testCborH) -} - -func TestJsonCodecsTable(t *testing.T) { - testCodecTableOne(t, testJsonH) -} - -func TestJsonCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testJsonH) -} - -func TestJsonCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testJsonH) -} - -func TestJsonCodecChan(t *testing.T) { - testCodecChan(t, testJsonH) -} - -func TestJsonStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, "json", testJsonH) -} - -func TestJsonMammoth(t *testing.T) { - testMammoth(t, "json", testJsonH) -} - -// ----- Raw --------- -func TestJsonRaw(t *testing.T) { - doTestRawValue(t, "json", testJsonH) -} -func TestBincRaw(t *testing.T) { - doTestRawValue(t, "binc", testBincH) -} -func TestMsgpackRaw(t *testing.T) { - doTestRawValue(t, "msgpack", testMsgpackH) -} -func TestSimpleRaw(t *testing.T) { - doTestRawValue(t, "simple", testSimpleH) -} -func TestCborRaw(t *testing.T) { - doTestRawValue(t, "cbor", testCborH) -} - -// ----- ALL (framework based) ----- - -func TestAllEncCircularRef(t *testing.T) { - doTestEncCircularRef(t, "cbor", testCborH) -} - -func TestAllAnonCycle(t *testing.T) { - doTestAnonCycle(t, "cbor", testCborH) -} - -// ----- RPC ----- - -func TestBincRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testBincH, true, 0) -} - -func TestSimpleRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testSimpleH, true, 0) -} - -func TestMsgpackRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testMsgpackH, true, 0) -} - -func TestCborRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testCborH, true, 0) -} - -func TestJsonRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testJsonH, true, 0) -} - -func TestMsgpackRpcSpec(t *testing.T) { - testCodecRpcOne(t, MsgpackSpecRpc, testMsgpackH, true, 0) -} - -func TestBincUnderlyingType(t *testing.T) { - testCodecUnderlyingType(t, testBincH) -} - -func TestJsonLargeInteger(t *testing.T) { - for _, i := range []uint8{'L', 'A', 0} { - for _, j := range []interface{}{ - int64(1 << 60), - -int64(1 << 60), - 0, - 1 << 20, - -(1 << 20), - uint64(1 << 60), - uint(0), - uint(1 << 20), - } { - doTestJsonLargeInteger(t, j, i) - } - } -} - -func TestJsonDecodeNonStringScalarInStringContext(t *testing.T) { - var b = `{"s.true": "true", "b.true": true, "s.false": "false", "b.false": false, "s.10": "10", "i.10": 10, "i.-10": -10}` - var golden = map[string]string{"s.true": "true", "b.true": "true", "s.false": "false", "b.false": "false", "s.10": "10", "i.10": "10", "i.-10": "-10"} - - var m map[string]string - d := NewDecoderBytes([]byte(b), testJsonH) - d.MustDecode(&m) - if err := deepEqual(golden, m); err == nil { - logT(t, "++++ match: decoded: %#v", m) - } else { - logT(t, "---- mismatch: %v ==> golden: %#v, decoded: %#v", err, golden, m) - failT(t) - } -} - -func TestJsonEncodeIndent(t *testing.T) { - v := TestSimplish{ - Ii: -794, - Ss: `A Man is -after the new line - after new line and tab -`, - } - v2 := v - v.Mm = make(map[string]*TestSimplish) - for i := 0; i < len(v.Ar); i++ { - v3 := v2 - v3.Ii += (i * 4) - v3.Ss = fmt.Sprintf("%d - %s", v3.Ii, v3.Ss) - if i%2 == 0 { - v.Ar[i] = &v3 - } - // v3 = v2 - v.Sl = append(v.Sl, &v3) - v.Mm[strconv.FormatInt(int64(i), 10)] = &v3 - } - oldcan := testJsonH.Canonical - oldIndent := testJsonH.Indent - oldS2A := testJsonH.StructToArray - defer func() { - testJsonH.Canonical = oldcan - testJsonH.Indent = oldIndent - testJsonH.StructToArray = oldS2A - }() - testJsonH.Canonical = true - testJsonH.Indent = -1 - testJsonH.StructToArray = false - var bs []byte - NewEncoderBytes(&bs, testJsonH).MustEncode(&v) - txt1Tab := string(bs) - bs = nil - testJsonH.Indent = 120 - NewEncoderBytes(&bs, testJsonH).MustEncode(&v) - txtSpaces := string(bs) - // fmt.Printf("\n-----------\n%s\n------------\n%s\n-------------\n", txt1Tab, txtSpaces) - - goldenResultTab := `{ - "Ar": [ - { - "Ar": [ - null, - null - ], - "Ii": -794, - "Mm": null, - "Sl": null, - "Ss": "-794 - A Man is\nafter the new line\n\tafter new line and tab\n" - }, - null - ], - "Ii": -794, - "Mm": { - "0": { - "Ar": [ - null, - null - ], - "Ii": -794, - "Mm": null, - "Sl": null, - "Ss": "-794 - A Man is\nafter the new line\n\tafter new line and tab\n" - }, - "1": { - "Ar": [ - null, - null - ], - "Ii": -790, - "Mm": null, - "Sl": null, - "Ss": "-790 - A Man is\nafter the new line\n\tafter new line and tab\n" - } - }, - "Sl": [ - { - "Ar": [ - null, - null - ], - "Ii": -794, - "Mm": null, - "Sl": null, - "Ss": "-794 - A Man is\nafter the new line\n\tafter new line and tab\n" - }, - { - "Ar": [ - null, - null - ], - "Ii": -790, - "Mm": null, - "Sl": null, - "Ss": "-790 - A Man is\nafter the new line\n\tafter new line and tab\n" - } - ], - "Ss": "A Man is\nafter the new line\n\tafter new line and tab\n" -}` - - if txt1Tab != goldenResultTab { - logT(t, "decoded indented with tabs != expected: \nexpected: %s\nencoded: %s", goldenResultTab, txt1Tab) - failT(t) - } - if txtSpaces != strings.Replace(goldenResultTab, "\t", strings.Repeat(" ", 120), -1) { - logT(t, "decoded indented with spaces != expected: \nexpected: %s\nencoded: %s", goldenResultTab, txtSpaces) - failT(t) - } -} - -// TODO: -// Add Tests for: -// - decoding empty list/map in stream into a nil slice/map -// - binary(M|Unm)arsher support for time.Time (e.g. cbor encoding) -// - text(M|Unm)arshaler support for time.Time (e.g. json encoding) -// - non fast-path scenarios e.g. map[string]uint16, []customStruct. -// Expand cbor to include indefinite length stuff for this non-fast-path types. -// This may not be necessary, since we have the manual tests (fastpathEnabled=false) to test/validate with. -// - CodecSelfer -// Ensure it is called when (en|de)coding interface{} or reflect.Value (2 different codepaths). -// - interfaces: textMarshaler, binaryMarshaler, codecSelfer -// - struct tags: -// on anonymous fields, _struct (all fields), etc -// - codecgen of struct containing channels. -// -// Add negative tests for failure conditions: -// - bad input with large array length prefix diff --git a/vendor/github.com/ugorji/go/codec/codecgen/README.md b/vendor/github.com/ugorji/go/codec/codecgen/README.md deleted file mode 100644 index 854b64bfcf..0000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# codecgen tool - -Generate is given a list of *.go files to parse, and an output file (fout), -codecgen will create an output file __file.go__ which -contains `codec.Selfer` implementations for the named types found -in the files parsed. - -Using codecgen is very straightforward. - -**Download and install the tool** - -`go get -u github.com/ugorji/go/codec/codecgen` - -**Run the tool on your files** - -The command line format is: - -`codecgen [options] (-o outfile) (infile ...)` - -```sh -% codecgen -? -Usage of codecgen: - -c="github.com/ugorji/go/codec": codec path - -o="": out file - -r=".*": regex for type name to match - -nr="": regex for type name to exclude - -rt="": tags for go run - -t="": build tag to put in file - -u=false: Use unsafe, e.g. to avoid unnecessary allocation on []byte->string - -x=false: keep temp file - -% codecgen -o values_codecgen.go values.go values2.go moretypedefs.go -``` - -Please see the [blog article](http://ugorji.net/blog/go-codecgen) -for more information on how to use the tool. - diff --git a/vendor/github.com/ugorji/go/codec/codecgen_test.go b/vendor/github.com/ugorji/go/codec/codecgen_test.go deleted file mode 100644 index 586af774b6..0000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build x,codecgen - -package codec - -import ( - "fmt" - "testing" -) - -func _TestCodecgenJson1(t *testing.T) { - // This is just a simplistic test for codecgen. - // It is typically disabled. We only enable it for debugging purposes. - const callCodecgenDirect bool = true - v := newTestStruc(2, false, !testSkipIntf, false) - var bs []byte - e := NewEncoderBytes(&bs, testJsonH) - if callCodecgenDirect { - v.CodecEncodeSelf(e) - e.w.atEndOfEncode() - } else { - e.MustEncode(v) - } - fmt.Printf("%s\n", bs) -} diff --git a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl deleted file mode 100644 index 0ce15ded0e..0000000000 --- a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl +++ /dev/null @@ -1,473 +0,0 @@ -// +build !notfastpath - -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl -// ************************************************************ - -package codec - -// Fast path functions try to create a fast path encode or decode implementation -// for common maps and slices. -// -// We define the functions and register then in this single file -// so as not to pollute the encode.go and decode.go, and create a dependency in there. -// This file can be omitted without causing a build failure. -// -// The advantage of fast paths is: -// - Many calls bypass reflection altogether -// -// Currently support -// - slice of all builtin types, -// - map of all builtin types to string or interface value -// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8) -// This should provide adequate "typical" implementations. -// -// Note that fast track decode functions must handle values for which an address cannot be obtained. -// For example: -// m2 := map[string]int{} -// p2 := []interface{}{m2} -// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. -// - -import ( - "reflect" - "sort" -) - -const fastpathEnabled = true - -const fastpathCheckNilFalse = false // for reflect -const fastpathCheckNilTrue = true // for type switch - -type fastpathT struct {} - -var fastpathTV fastpathT - -type fastpathE struct { - rtid uintptr - rt reflect.Type - encfn func(*encFnInfo, reflect.Value) - decfn func(*decFnInfo, reflect.Value) -} - -type fastpathA [{{ .FastpathLen }}]fastpathE - -func (x *fastpathA) index(rtid uintptr) int { - // use binary search to grab the index (adapted from sort/search.go) - h, i, j := 0, 0, {{ .FastpathLen }} // len(x) - for i < j { - h = i + (j-i)/2 - if x[h].rtid < rtid { - i = h + 1 - } else { - j = h - } - } - if i < {{ .FastpathLen }} && x[i].rtid == rtid { - return i - } - return -1 -} - -type fastpathAslice []fastpathE - -func (x fastpathAslice) Len() int { return len(x) } -func (x fastpathAslice) Less(i, j int) bool { return x[i].rtid < x[j].rtid } -func (x fastpathAslice) Swap(i, j int) { x[i], x[j] = x[j], x[i] } - -var fastpathAV fastpathA - -// due to possible initialization loop error, make fastpath in an init() -func init() { - i := 0 - fn := func(v interface{}, fe func(*encFnInfo, reflect.Value), fd func(*decFnInfo, reflect.Value)) (f fastpathE) { - xrt := reflect.TypeOf(v) - xptr := rt2id(xrt) - fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} - i++ - return - } - - {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - fn([]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} - - {{range .Values}}{{if not .Primitive}}{{if .MapKey }} - fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} - - sort.Sort(fastpathAslice(fastpathAV[:])) -} - -// -- encode - -// -- -- fast path type switch -func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - case []{{ .Elem }}:{{else}} - case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e){{if not .MapKey }} - case *[]{{ .Elem }}:{{else}} - case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) -{{end}}{{end}} - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) - return false - } - return true -} - -func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - case []{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) - case *[]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) -{{end}}{{end}}{{end}} - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) - return false - } - return true -} - -func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if .MapKey }} - case map[{{ .MapKey }}]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) - case *map[{{ .MapKey }}]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) -{{end}}{{end}}{{end}} - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) - return false - } - return true -} - -// -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - -func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { - if f.ti.mbs { - fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv2i(rv).([]{{ .Elem }}), fastpathCheckNilFalse, f.e) - } else { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).([]{{ .Elem }}), fastpathCheckNilFalse, f.e) - } -} -func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) { - ee := e.e - cr := e.cr - if checkNil && v == nil { - ee.EncodeNil() - return - } - ee.EncodeArrayStart(len(v)) - for _, v2 := range v { - if cr != nil { cr.sendContainerState(containerArrayElem) } - {{ encmd .Elem "v2"}} - } - if cr != nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}} -} - -func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) { - ee := e.e - cr := e.cr - if checkNil && v == nil { - ee.EncodeNil() - return - } - if len(v)%2 == 1 { - e.errorf("mapBySlice requires even slice length, but got %v", len(v)) - return - } - ee.EncodeMapStart(len(v) / 2) - for j, v2 := range v { - if cr != nil { - if j%2 == 0 { - cr.sendContainerState(containerMapKey) - } else { - cr.sendContainerState(containerMapValue) - } - } - {{ encmd .Elem "v2"}} - } - if cr != nil { cr.sendContainerState(containerMapEnd) } -} - -{{end}}{{end}}{{end}} - -{{range .Values}}{{if not .Primitive}}{{if .MapKey }} - -func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), fastpathCheckNilFalse, f.e) -} -func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, e *Encoder) { - ee := e.e - cr := e.cr - if checkNil && v == nil { - ee.EncodeNil() - return - } - ee.EncodeMapStart(len(v)) - {{if eq .MapKey "string"}}asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 - {{end}}if e.h.Canonical { - {{if eq .MapKey "interface{}"}}{{/* out of band - */}}var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding - e2 := NewEncoderBytes(&mksv, e.hh) - v2 := make([]bytesI, len(v)) - var i, l int - var vp *bytesI {{/* put loop variables outside. seems currently needed for better perf */}} - for k2, _ := range v { - l = len(mksv) - e2.MustEncode(k2) - vp = &v2[i] - vp.v = mksv[l:] - vp.i = k2 - i++ - } - sort.Sort(bytesISlice(v2)) - for j := range v2 { - if cr != nil { cr.sendContainerState(containerMapKey) } - e.asis(v2[j].v) - if cr != nil { cr.sendContainerState(containerMapValue) } - e.encode(v[v2[j].i]) - } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) - var i int - for k, _ := range v { - v2[i] = {{ $x }}(k) - i++ - } - sort.Sort({{ sorttype .MapKey false}}(v2)) - for _, k2 := range v2 { - if cr != nil { cr.sendContainerState(containerMapKey) } - {{if eq .MapKey "string"}}if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - }{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} - if cr != nil { cr.sendContainerState(containerMapValue) } - {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }} - } {{end}} - } else { - for k2, v2 := range v { - if cr != nil { cr.sendContainerState(containerMapKey) } - {{if eq .MapKey "string"}}if asSymbols { - ee.EncodeSymbol(k2) - } else { - ee.EncodeString(c_UTF8, k2) - }{{else}}{{ encmd .MapKey "k2"}}{{end}} - if cr != nil { cr.sendContainerState(containerMapValue) } - {{ encmd .Elem "v2"}} - } - } - if cr != nil { cr.sendContainerState(containerMapEnd) }{{/* ee.EncodeEnd() */}} -} - -{{end}}{{end}}{{end}} - -// -- decode - -// -- -- fast path type switch -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} - case []{{ .Elem }}:{{else}} - case map[{{ .MapKey }}]{{ .Elem }}:{{end}} - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, d){{if not .MapKey }} - case *[]{{ .Elem }}:{{else}} - case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} - v2, changed2 := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, fastpathCheckNilFalse, true, d) - if changed2 { - *v = v2 - } -{{end}}{{end}} - default: - _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) - return false - } - return true -} - -// -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} -{{/* -Slices can change if they -- did not come from an array -- are addressable (from a ptr) -- are settable (e.g. contained in an interface{}) -*/}} -func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { - array := f.seq == seqTypeArray - if !array && rv.CanAddr() { {{/* // CanSet => CanAddr + Exported */}} - vp := rv2i(rv.Addr()).(*[]{{ .Elem }}) - v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, !array, f.d) - if changed { - *vp = v - } - } else { - v := rv2i(rv).([]{{ .Elem }}) - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d) - } -} - -func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, checkNil bool, d *Decoder) { - v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d) - if changed { - *vp = v - } -} -func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, checkNil bool, canChange bool, d *Decoder) (_ []{{ .Elem }}, changed bool) { - dd := d.d - {{/* // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() */}} - if checkNil && dd.TryDecodeAsNil() { - if v != nil { changed = true } - return nil, changed - } - slh, containerLenS := d.decSliceHelperStart() - if containerLenS == 0 { - if canChange { - if v == nil { - v = []{{ .Elem }}{} - } else if len(v) != 0 { - v = v[:0] - } - changed = true - } - slh.End() - return v, changed - } - - hasLen := containerLenS > 0 - var xlen int - if hasLen && canChange { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) - if xlen <= cap(v) { - v = v[:xlen] - } else { - v = make([]{{ .Elem }}, xlen) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - j := 0 - for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) - } else { - xlen = 8 - } - v = make([]{{ .Elem }}, xlen) - changed = true - } - // if indefinite, etc, then expand the slice if necessary - var decodeIntoBlank bool - if j >= len(v) { - if canChange { - v = append(v, {{ zerocmd .Elem }}) - changed = true - } else { - d.arrayCannotExpand(len(v), j+1) - decodeIntoBlank = true - } - } - slh.ElemContainerState(j) - if decodeIntoBlank { - d.swallow() - } else { - {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} - } - } - if canChange { - if j < len(v) { - v = v[:j] - changed = true - } else if j == 0 && v == nil { - v = make([]{{ .Elem }}, 0) - changed = true - } - } - slh.End() - return v, changed -} - -{{end}}{{end}}{{end}} - - -{{range .Values}}{{if not .Primitive}}{{if .MapKey }} -{{/* -Maps can change if they are -- addressable (from a ptr) -- settable (e.g. contained in an interface{}) -*/}} -func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { - if rv.CanAddr() { - vp := rv2i(rv.Addr()).(*map[{{ .MapKey }}]{{ .Elem }}) - v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, true, f.d) - if changed { - *vp = v - } - } else { - v := rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}) - fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d) - } -} -func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, d *Decoder) { - v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d) - if changed { - *vp = v - } -} -func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, canChange bool, - d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) { - dd := d.d - cr := d.cr - {{/* // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() */}} - if checkNil && dd.TryDecodeAsNil() { - if v != nil { changed = true } - return nil, changed - } - containerLen := dd.ReadMapStart() - if canChange && v == nil { - xlen := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}) - v = make(map[{{ .MapKey }}]{{ .Elem }}, xlen) - changed = true - } - if containerLen == 0 { - if cr != nil { cr.sendContainerState(containerMapEnd) } - return v, changed - } - {{ if eq .Elem "interface{}" }}mapGet := !d.h.MapValueReset && !d.h.InterfaceReset{{end}} - var mk {{ .MapKey }} - var mv {{ .Elem }} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ { - if cr != nil { cr.sendContainerState(containerMapKey) } - {{ if eq .MapKey "interface{}" }}mk = nil - d.decode(&mk) - if bv, bok := mk.([]byte); bok { - mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} - }{{ else }}mk = {{ decmd .MapKey }}{{ end }} - if cr != nil { cr.sendContainerState(containerMapValue) } - {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil } - d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }} - if v != nil { - v[mk] = mv - } - } - if cr != nil { cr.sendContainerState(containerMapEnd) } - return v, changed -} - -{{end}}{{end}}{{end}} diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl deleted file mode 100644 index f4f0cdd27e..0000000000 --- a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl +++ /dev/null @@ -1,70 +0,0 @@ -{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}} -var {{var "c"}} bool {{/* // changed */}} -_ = {{var "c"}}{{end}} -if {{var "l"}} == 0 { - {{if isSlice }}if {{var "v"}} == nil { - {{var "v"}} = []{{ .Typ }}{} - {{var "c"}} = true - } else if len({{var "v"}}) != 0 { - {{var "v"}} = {{var "v"}}[:0] - {{var "c"}} = true - } {{end}} {{if isChan }}if {{var "v"}} == nil { - {{var "v"}} = make({{ .CTyp }}, 0) - {{var "c"}} = true - } {{end}} -} else { - {{var "hl"}} := {{var "l"}} > 0 - var {{var "rl"}} int - {{if isSlice }} if {{var "hl"}} { - if {{var "l"}} > cap({{var "v"}}) { - {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - if {{var "rl"}} <= cap({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "rl"}}] - } else { - {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}}) - } - {{var "c"}} = true - } else if {{var "l"}} != len({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "l"}}] - {{var "c"}} = true - } - } {{end}} - {{var "j"}} := 0 - for ; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { - if {{var "j"}} == 0 && len({{var "v"}}) == 0 { - if {{var "hl"}} { - {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - } else { - {{var "rl"}} = 8 - } - {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}}) - {{var "c"}} = true - } - // if indefinite, etc, then expand the slice if necessary - var {{var "db"}} bool - if {{var "j"}} >= len({{var "v"}}) { - {{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }}); {{var "c"}} = true - {{end}} {{if isArray}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true - {{end}} - } - {{var "h"}}.ElemContainerState({{var "j"}}) - if {{var "db"}} { - z.DecSwallow() - } else { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }} - } - } - {{if isSlice}} if {{var "j"}} < len({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "j"}}] - {{var "c"}} = true - } else if {{var "j"}} == 0 && {{var "v"}} == nil { - {{var "v"}} = make([]{{ .Typ }}, 0) - {{var "c"}} = true - } {{end}} -} -{{var "h"}}.End() -{{if not isArray }}if {{var "c"}} { - *{{ .Varname }} = {{var "v"}} -}{{end}} - diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl deleted file mode 100644 index 423d638528..0000000000 --- a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl +++ /dev/null @@ -1,39 +0,0 @@ -{{var "v"}} := *{{ .Varname }} -{{var "l"}} := r.ReadMapStart() -{{var "bh"}} := z.DecBasicHandle() -if {{var "v"}} == nil { - {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }}) - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}}) - *{{ .Varname }} = {{var "v"}} -} -var {{var "mk"}} {{ .KTyp }} -var {{var "mv"}} {{ .Typ }} -var {{var "mg"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool -if {{var "bh"}}.MapValueReset { - {{if decElemKindPtr}}{{var "mg"}} = true - {{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true } - {{else if not decElemKindImmutable}}{{var "mg"}} = true - {{end}} } -if {{var "l"}} != 0 { -{{var "hl"}} := {{var "l"}} > 0 - for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { - z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) - {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }} -{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { - {{var "mk"}} = string({{var "bv"}}) - }{{ end }}{{if decElemKindPtr}} - {{var "ms"}} = true{{end}} - if {{var "mg"}} { - {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] - if {{var "mok"}} { - {{var "ms"}} = false - } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}} - } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} - z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }} - if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -} // else len==0: TODO: Should we clear map entries? -z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl deleted file mode 100644 index 2d801c8170..0000000000 --- a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl +++ /dev/null @@ -1,381 +0,0 @@ -/* // +build ignore */ - -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl -// ************************************************************ - -package codec - -import ( - "encoding" - "reflect" -) - -// GenVersion is the current version of codecgen. -const GenVersion = {{ .Version }} - -// This file is used to generate helper code for codecgen. -// The values here i.e. genHelper(En|De)coder are not to be used directly by -// library users. They WILL change continuously and without notice. -// -// To help enforce this, we create an unexported type with exported members. -// The only way to get the type is via the one exported type that we control (somewhat). -// -// When static codecs are created for types, they will use this value -// to perform encoding or decoding of primitives or known slice or map types. - -// GenHelperEncoder is exported so that it can be used externally by codecgen. -// -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) { - return genHelperEncoder{e:e}, e.e -} - -// GenHelperDecoder is exported so that it can be used externally by codecgen. -// -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE. -func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) { - return genHelperDecoder{d:d}, d.d -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperEncoder struct { - e *Encoder - F fastpathT -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperDecoder struct { - d *Decoder - F fastpathT -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBasicHandle() *BasicHandle { - return f.e.h -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBinary() bool { - return f.e.be // f.e.hh.isBinaryEncoding() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncFallback(iv interface{}) { - // println(">>>>>>>>> EncFallback") - f.e.encodeI(iv, false, false) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) { - bs, fnerr := iv.MarshalText() - f.e.marshal(bs, fnerr, false, c_UTF8) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) { - bs, fnerr := iv.MarshalJSON() - f.e.marshal(bs, fnerr, true, c_UTF8) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) { - bs, fnerr := iv.MarshalBinary() - f.e.marshal(bs, fnerr, false, c_RAW) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncRaw(iv Raw) { - f.e.raw(iv) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) TimeRtidIfBinc() uintptr { - if _, ok := f.e.hh.(*BincHandle); ok { - return timeTypId - } - return 0 -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) IsJSONHandle() bool { - return f.e.js -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) HasExtensions() bool { - return len(f.e.h.extHandle) != 0 -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncExt(v interface{}) (r bool) { - rt := reflect.TypeOf(v) - if rt.Kind() == reflect.Ptr { - rt = rt.Elem() - } - rtid := rt2id(rt) - if xfFn := f.e.h.getExt(rtid); xfFn != nil { - f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e) - return true - } - return false -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncSendContainerState(c containerState) { - if f.e.cr != nil { - f.e.cr.sendContainerState(c) - } -} - -// ---------------- DECODER FOLLOWS ----------------- - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBasicHandle() *BasicHandle { - return f.d.h -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBinary() bool { - return f.d.be // f.d.hh.isBinaryEncoding() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSwallow() { - f.d.swallow() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecScratchBuffer() []byte { - return f.d.b[:] -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) { - // println(">>>>>>>>> DecFallback") - f.d.decodeI(iv, chkPtr, false, false, false) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) { - return f.d.decSliceHelperStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) { - f.d.structFieldNotFound(index, name) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) { - f.d.arrayCannotExpand(sliceLen, streamLen) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) { - fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()) - if fnerr != nil { - panic(fnerr) - } -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) { - // bs := f.dd.DecodeStringAsBytes() - // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself. - fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()) - if fnerr != nil { - panic(fnerr) - } -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { - fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)) - if fnerr != nil { - panic(fnerr) - } -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecRaw() []byte { - return f.d.raw() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) TimeRtidIfBinc() uintptr { - if _, ok := f.d.hh.(*BincHandle); ok { - return timeTypId - } - return 0 -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) IsJSONHandle() bool { - return f.d.js -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) HasExtensions() bool { - return len(f.d.h.extHandle) != 0 -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecExt(v interface{}) (r bool) { - rt := reflect.TypeOf(v).Elem() - rtid := rt2id(rt) - if xfFn := f.d.h.getExt(rtid); xfFn != nil { - f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) - return true - } - return false -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) { - return decInferLen(clen, maxlen, unit) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) StringView(v []byte) string { - return stringView(v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecSendContainerState(c containerState) { - if f.d.cr != nil { - f.d.cr.sendContainerState(c) - } -} - -{{/* - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncDriver() encDriver { - return f.e.e -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDriver() decDriver { - return f.d.d -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncNil() { - f.e.e.EncodeNil() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncBytes(v []byte) { - f.e.e.EncodeStringBytes(c_RAW, v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayStart(length int) { - f.e.e.EncodeArrayStart(length) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayEnd() { - f.e.e.EncodeArrayEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncArrayEntrySeparator() { - f.e.e.EncodeArrayEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapStart(length int) { - f.e.e.EncodeMapStart(length) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapEnd() { - f.e.e.EncodeMapEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapEntrySeparator() { - f.e.e.EncodeMapEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncMapKVSeparator() { - f.e.e.EncodeMapKVSeparator() -} - -// --------- - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBytes(v *[]byte) { - *v = f.d.d.DecodeBytes(*v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecTryNil() bool { - return f.d.d.TryDecodeAsNil() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsNil() (b bool) { - return f.d.d.IsContainerType(valueTypeNil) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsMap() (b bool) { - return f.d.d.IsContainerType(valueTypeMap) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecContainerIsArray() (b bool) { - return f.d.d.IsContainerType(valueTypeArray) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecCheckBreak() bool { - return f.d.d.CheckBreak() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapStart() int { - return f.d.d.ReadMapStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayStart() int { - return f.d.d.ReadArrayStart() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapEnd() { - f.d.d.ReadMapEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayEnd() { - f.d.d.ReadArrayEnd() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecArrayEntrySeparator() { - f.d.d.ReadArrayEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapEntrySeparator() { - f.d.d.ReadMapEntrySeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecMapKVSeparator() { - f.d.d.ReadMapKVSeparator() -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) ReadStringAsBytes(bs []byte) []byte { - return f.d.d.DecodeStringAsBytes(bs) -} - - -// -- encode calls (primitives) -{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" true }}(v {{ .Primitive }}) { - ee := f.e.e - {{ encmd .Primitive "v" }} -} -{{ end }}{{ end }}{{ end }} - -// -- decode calls (primitives) -{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) {{ .MethodNamePfx "Dec" true }}(vp *{{ .Primitive }}) { - dd := f.d.d - *vp = {{ decmd .Primitive }} -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) {{ .MethodNamePfx "Read" true }}() (v {{ .Primitive }}) { - dd := f.d.d - v = {{ decmd .Primitive }} - return -} -{{ end }}{{ end }}{{ end }} - - -// -- encode calls (slices/maps) -{{range .Values}}{{if not .Primitive }}{{if .Slice }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v []{{ .Elem }}) { {{ else }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v map[{{ .MapKey }}]{{ .Elem }}) { {{end}} - f.F.{{ .MethodNamePfx "Enc" false }}V(v, false, f.e) -} -{{ end }}{{ end }} - -// -- decode calls (slices/maps) -{{range .Values}}{{if not .Primitive }} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -{{if .Slice }}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *[]{{ .Elem }}) { -{{else}}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *map[{{ .MapKey }}]{{ .Elem }}) { {{end}} - v, changed := f.F.{{ .MethodNamePfx "Dec" false }}V(*vp, false, true, f.d) - if changed { - *vp = v - } -} -{{ end }}{{ end }} -*/}} diff --git a/vendor/github.com/ugorji/go/codec/helper_test.go b/vendor/github.com/ugorji/go/codec/helper_test.go deleted file mode 100644 index 611eac43d1..0000000000 --- a/vendor/github.com/ugorji/go/codec/helper_test.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// All non-std package dependencies related to testing live in this file, -// so porting to different environment is easy (just update functions). - -import ( - "errors" - "fmt" - "reflect" - "testing" -) - -// ----- functions below are used only by tests (not benchmarks) - -const ( - testLogToT = true - failNowOnFail = true -) - -func checkErrT(t *testing.T, err error) { - if err != nil { - logT(t, err.Error()) - failT(t) - } -} - -func checkEqualT(t *testing.T, v1 interface{}, v2 interface{}, desc string) (err error) { - if err = deepEqual(v1, v2); err != nil { - logT(t, "Not Equal: %s: %v. v1: %v, v2: %v", desc, err, v1, v2) - failT(t) - } - return -} - -func failT(t *testing.T) { - if failNowOnFail { - t.FailNow() - } else { - t.Fail() - } -} - -// --- these functions are used by both benchmarks and tests - -func deepEqual(v1, v2 interface{}) (err error) { - if !reflect.DeepEqual(v1, v2) { - err = errors.New("Not Match") - } - return -} - -func logT(x interface{}, format string, args ...interface{}) { - if t, ok := x.(*testing.T); ok && t != nil && testLogToT { - if testVerbose { - t.Logf(format, args...) - } - } else if b, ok := x.(*testing.B); ok && b != nil && testLogToT { - b.Logf(format, args...) - } else { - if len(format) == 0 || format[len(format)-1] != '\n' { - format = format + "\n" - } - fmt.Printf(format, args...) - } -} - -func approxDataSize(rv reflect.Value) (sum int) { - switch rk := rv.Kind(); rk { - case reflect.Invalid: - case reflect.Ptr, reflect.Interface: - sum += int(rv.Type().Size()) - sum += approxDataSize(rv.Elem()) - case reflect.Slice: - sum += int(rv.Type().Size()) - for j := 0; j < rv.Len(); j++ { - sum += approxDataSize(rv.Index(j)) - } - case reflect.String: - sum += int(rv.Type().Size()) - sum += rv.Len() - case reflect.Map: - sum += int(rv.Type().Size()) - for _, mk := range rv.MapKeys() { - sum += approxDataSize(mk) - sum += approxDataSize(rv.MapIndex(mk)) - } - case reflect.Struct: - //struct size already includes the full data size. - //sum += int(rv.Type().Size()) - for j := 0; j < rv.NumField(); j++ { - sum += approxDataSize(rv.Field(j)) - } - default: - //pure value types - sum += int(rv.Type().Size()) - } - return -} diff --git a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl deleted file mode 100644 index 6d716972a0..0000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from mammoth-test.go.tmpl -// ************************************************************ - -package codec - -// TestMammoth has all the different paths optimized in fast-path -// It has all the primitives, slices and maps. -// -// For each of those types, it has a pointer and a non-pointer field. - -type TestMammoth struct { - -{{range .Values }}{{if .Primitive }}{{/* -*/}}{{ .MethodNamePfx "F" true }} {{ .Primitive }} -{{ .MethodNamePfx "Fptr" true }} *{{ .Primitive }} -{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/* -*/}}{{ .MethodNamePfx "F" false }} []{{ .Elem }} -{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }} -{{end}}{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/* -*/}}{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }} -{{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }} -{{end}}{{end}}{{end}} - -} diff --git a/vendor/github.com/ugorji/go/codec/mammoth_generated_test.go b/vendor/github.com/ugorji/go/codec/mammoth_generated_test.go deleted file mode 100644 index 73c2a7c15b..0000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth_generated_test.go +++ /dev/null @@ -1,593 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// ************************************************************ -// DO NOT EDIT. -// THIS FILE IS AUTO-GENERATED from mammoth-test.go.tmpl -// ************************************************************ - -package codec - -// TestMammoth has all the different paths optimized in fast-path -// It has all the primitives, slices and maps. -// -// For each of those types, it has a pointer and a non-pointer field. - -type TestMammoth struct { - FIntf interface{} - FptrIntf *interface{} - FString string - FptrString *string - FFloat32 float32 - FptrFloat32 *float32 - FFloat64 float64 - FptrFloat64 *float64 - FUint uint - FptrUint *uint - FUint8 uint8 - FptrUint8 *uint8 - FUint16 uint16 - FptrUint16 *uint16 - FUint32 uint32 - FptrUint32 *uint32 - FUint64 uint64 - FptrUint64 *uint64 - FUintptr uintptr - FptrUintptr *uintptr - FInt int - FptrInt *int - FInt8 int8 - FptrInt8 *int8 - FInt16 int16 - FptrInt16 *int16 - FInt32 int32 - FptrInt32 *int32 - FInt64 int64 - FptrInt64 *int64 - FBool bool - FptrBool *bool - - FSliceIntf []interface{} - FptrSliceIntf *[]interface{} - FSliceString []string - FptrSliceString *[]string - FSliceFloat32 []float32 - FptrSliceFloat32 *[]float32 - FSliceFloat64 []float64 - FptrSliceFloat64 *[]float64 - FSliceUint []uint - FptrSliceUint *[]uint - FSliceUint16 []uint16 - FptrSliceUint16 *[]uint16 - FSliceUint32 []uint32 - FptrSliceUint32 *[]uint32 - FSliceUint64 []uint64 - FptrSliceUint64 *[]uint64 - FSliceUintptr []uintptr - FptrSliceUintptr *[]uintptr - FSliceInt []int - FptrSliceInt *[]int - FSliceInt8 []int8 - FptrSliceInt8 *[]int8 - FSliceInt16 []int16 - FptrSliceInt16 *[]int16 - FSliceInt32 []int32 - FptrSliceInt32 *[]int32 - FSliceInt64 []int64 - FptrSliceInt64 *[]int64 - FSliceBool []bool - FptrSliceBool *[]bool - - FMapIntfIntf map[interface{}]interface{} - FptrMapIntfIntf *map[interface{}]interface{} - FMapIntfString map[interface{}]string - FptrMapIntfString *map[interface{}]string - FMapIntfUint map[interface{}]uint - FptrMapIntfUint *map[interface{}]uint - FMapIntfUint8 map[interface{}]uint8 - FptrMapIntfUint8 *map[interface{}]uint8 - FMapIntfUint16 map[interface{}]uint16 - FptrMapIntfUint16 *map[interface{}]uint16 - FMapIntfUint32 map[interface{}]uint32 - FptrMapIntfUint32 *map[interface{}]uint32 - FMapIntfUint64 map[interface{}]uint64 - FptrMapIntfUint64 *map[interface{}]uint64 - FMapIntfUintptr map[interface{}]uintptr - FptrMapIntfUintptr *map[interface{}]uintptr - FMapIntfInt map[interface{}]int - FptrMapIntfInt *map[interface{}]int - FMapIntfInt8 map[interface{}]int8 - FptrMapIntfInt8 *map[interface{}]int8 - FMapIntfInt16 map[interface{}]int16 - FptrMapIntfInt16 *map[interface{}]int16 - FMapIntfInt32 map[interface{}]int32 - FptrMapIntfInt32 *map[interface{}]int32 - FMapIntfInt64 map[interface{}]int64 - FptrMapIntfInt64 *map[interface{}]int64 - FMapIntfFloat32 map[interface{}]float32 - FptrMapIntfFloat32 *map[interface{}]float32 - FMapIntfFloat64 map[interface{}]float64 - FptrMapIntfFloat64 *map[interface{}]float64 - FMapIntfBool map[interface{}]bool - FptrMapIntfBool *map[interface{}]bool - FMapStringIntf map[string]interface{} - FptrMapStringIntf *map[string]interface{} - FMapStringString map[string]string - FptrMapStringString *map[string]string - FMapStringUint map[string]uint - FptrMapStringUint *map[string]uint - FMapStringUint8 map[string]uint8 - FptrMapStringUint8 *map[string]uint8 - FMapStringUint16 map[string]uint16 - FptrMapStringUint16 *map[string]uint16 - FMapStringUint32 map[string]uint32 - FptrMapStringUint32 *map[string]uint32 - FMapStringUint64 map[string]uint64 - FptrMapStringUint64 *map[string]uint64 - FMapStringUintptr map[string]uintptr - FptrMapStringUintptr *map[string]uintptr - FMapStringInt map[string]int - FptrMapStringInt *map[string]int - FMapStringInt8 map[string]int8 - FptrMapStringInt8 *map[string]int8 - FMapStringInt16 map[string]int16 - FptrMapStringInt16 *map[string]int16 - FMapStringInt32 map[string]int32 - FptrMapStringInt32 *map[string]int32 - FMapStringInt64 map[string]int64 - FptrMapStringInt64 *map[string]int64 - FMapStringFloat32 map[string]float32 - FptrMapStringFloat32 *map[string]float32 - FMapStringFloat64 map[string]float64 - FptrMapStringFloat64 *map[string]float64 - FMapStringBool map[string]bool - FptrMapStringBool *map[string]bool - FMapFloat32Intf map[float32]interface{} - FptrMapFloat32Intf *map[float32]interface{} - FMapFloat32String map[float32]string - FptrMapFloat32String *map[float32]string - FMapFloat32Uint map[float32]uint - FptrMapFloat32Uint *map[float32]uint - FMapFloat32Uint8 map[float32]uint8 - FptrMapFloat32Uint8 *map[float32]uint8 - FMapFloat32Uint16 map[float32]uint16 - FptrMapFloat32Uint16 *map[float32]uint16 - FMapFloat32Uint32 map[float32]uint32 - FptrMapFloat32Uint32 *map[float32]uint32 - FMapFloat32Uint64 map[float32]uint64 - FptrMapFloat32Uint64 *map[float32]uint64 - FMapFloat32Uintptr map[float32]uintptr - FptrMapFloat32Uintptr *map[float32]uintptr - FMapFloat32Int map[float32]int - FptrMapFloat32Int *map[float32]int - FMapFloat32Int8 map[float32]int8 - FptrMapFloat32Int8 *map[float32]int8 - FMapFloat32Int16 map[float32]int16 - FptrMapFloat32Int16 *map[float32]int16 - FMapFloat32Int32 map[float32]int32 - FptrMapFloat32Int32 *map[float32]int32 - FMapFloat32Int64 map[float32]int64 - FptrMapFloat32Int64 *map[float32]int64 - FMapFloat32Float32 map[float32]float32 - FptrMapFloat32Float32 *map[float32]float32 - FMapFloat32Float64 map[float32]float64 - FptrMapFloat32Float64 *map[float32]float64 - FMapFloat32Bool map[float32]bool - FptrMapFloat32Bool *map[float32]bool - FMapFloat64Intf map[float64]interface{} - FptrMapFloat64Intf *map[float64]interface{} - FMapFloat64String map[float64]string - FptrMapFloat64String *map[float64]string - FMapFloat64Uint map[float64]uint - FptrMapFloat64Uint *map[float64]uint - FMapFloat64Uint8 map[float64]uint8 - FptrMapFloat64Uint8 *map[float64]uint8 - FMapFloat64Uint16 map[float64]uint16 - FptrMapFloat64Uint16 *map[float64]uint16 - FMapFloat64Uint32 map[float64]uint32 - FptrMapFloat64Uint32 *map[float64]uint32 - FMapFloat64Uint64 map[float64]uint64 - FptrMapFloat64Uint64 *map[float64]uint64 - FMapFloat64Uintptr map[float64]uintptr - FptrMapFloat64Uintptr *map[float64]uintptr - FMapFloat64Int map[float64]int - FptrMapFloat64Int *map[float64]int - FMapFloat64Int8 map[float64]int8 - FptrMapFloat64Int8 *map[float64]int8 - FMapFloat64Int16 map[float64]int16 - FptrMapFloat64Int16 *map[float64]int16 - FMapFloat64Int32 map[float64]int32 - FptrMapFloat64Int32 *map[float64]int32 - FMapFloat64Int64 map[float64]int64 - FptrMapFloat64Int64 *map[float64]int64 - FMapFloat64Float32 map[float64]float32 - FptrMapFloat64Float32 *map[float64]float32 - FMapFloat64Float64 map[float64]float64 - FptrMapFloat64Float64 *map[float64]float64 - FMapFloat64Bool map[float64]bool - FptrMapFloat64Bool *map[float64]bool - FMapUintIntf map[uint]interface{} - FptrMapUintIntf *map[uint]interface{} - FMapUintString map[uint]string - FptrMapUintString *map[uint]string - FMapUintUint map[uint]uint - FptrMapUintUint *map[uint]uint - FMapUintUint8 map[uint]uint8 - FptrMapUintUint8 *map[uint]uint8 - FMapUintUint16 map[uint]uint16 - FptrMapUintUint16 *map[uint]uint16 - FMapUintUint32 map[uint]uint32 - FptrMapUintUint32 *map[uint]uint32 - FMapUintUint64 map[uint]uint64 - FptrMapUintUint64 *map[uint]uint64 - FMapUintUintptr map[uint]uintptr - FptrMapUintUintptr *map[uint]uintptr - FMapUintInt map[uint]int - FptrMapUintInt *map[uint]int - FMapUintInt8 map[uint]int8 - FptrMapUintInt8 *map[uint]int8 - FMapUintInt16 map[uint]int16 - FptrMapUintInt16 *map[uint]int16 - FMapUintInt32 map[uint]int32 - FptrMapUintInt32 *map[uint]int32 - FMapUintInt64 map[uint]int64 - FptrMapUintInt64 *map[uint]int64 - FMapUintFloat32 map[uint]float32 - FptrMapUintFloat32 *map[uint]float32 - FMapUintFloat64 map[uint]float64 - FptrMapUintFloat64 *map[uint]float64 - FMapUintBool map[uint]bool - FptrMapUintBool *map[uint]bool - FMapUint8Intf map[uint8]interface{} - FptrMapUint8Intf *map[uint8]interface{} - FMapUint8String map[uint8]string - FptrMapUint8String *map[uint8]string - FMapUint8Uint map[uint8]uint - FptrMapUint8Uint *map[uint8]uint - FMapUint8Uint8 map[uint8]uint8 - FptrMapUint8Uint8 *map[uint8]uint8 - FMapUint8Uint16 map[uint8]uint16 - FptrMapUint8Uint16 *map[uint8]uint16 - FMapUint8Uint32 map[uint8]uint32 - FptrMapUint8Uint32 *map[uint8]uint32 - FMapUint8Uint64 map[uint8]uint64 - FptrMapUint8Uint64 *map[uint8]uint64 - FMapUint8Uintptr map[uint8]uintptr - FptrMapUint8Uintptr *map[uint8]uintptr - FMapUint8Int map[uint8]int - FptrMapUint8Int *map[uint8]int - FMapUint8Int8 map[uint8]int8 - FptrMapUint8Int8 *map[uint8]int8 - FMapUint8Int16 map[uint8]int16 - FptrMapUint8Int16 *map[uint8]int16 - FMapUint8Int32 map[uint8]int32 - FptrMapUint8Int32 *map[uint8]int32 - FMapUint8Int64 map[uint8]int64 - FptrMapUint8Int64 *map[uint8]int64 - FMapUint8Float32 map[uint8]float32 - FptrMapUint8Float32 *map[uint8]float32 - FMapUint8Float64 map[uint8]float64 - FptrMapUint8Float64 *map[uint8]float64 - FMapUint8Bool map[uint8]bool - FptrMapUint8Bool *map[uint8]bool - FMapUint16Intf map[uint16]interface{} - FptrMapUint16Intf *map[uint16]interface{} - FMapUint16String map[uint16]string - FptrMapUint16String *map[uint16]string - FMapUint16Uint map[uint16]uint - FptrMapUint16Uint *map[uint16]uint - FMapUint16Uint8 map[uint16]uint8 - FptrMapUint16Uint8 *map[uint16]uint8 - FMapUint16Uint16 map[uint16]uint16 - FptrMapUint16Uint16 *map[uint16]uint16 - FMapUint16Uint32 map[uint16]uint32 - FptrMapUint16Uint32 *map[uint16]uint32 - FMapUint16Uint64 map[uint16]uint64 - FptrMapUint16Uint64 *map[uint16]uint64 - FMapUint16Uintptr map[uint16]uintptr - FptrMapUint16Uintptr *map[uint16]uintptr - FMapUint16Int map[uint16]int - FptrMapUint16Int *map[uint16]int - FMapUint16Int8 map[uint16]int8 - FptrMapUint16Int8 *map[uint16]int8 - FMapUint16Int16 map[uint16]int16 - FptrMapUint16Int16 *map[uint16]int16 - FMapUint16Int32 map[uint16]int32 - FptrMapUint16Int32 *map[uint16]int32 - FMapUint16Int64 map[uint16]int64 - FptrMapUint16Int64 *map[uint16]int64 - FMapUint16Float32 map[uint16]float32 - FptrMapUint16Float32 *map[uint16]float32 - FMapUint16Float64 map[uint16]float64 - FptrMapUint16Float64 *map[uint16]float64 - FMapUint16Bool map[uint16]bool - FptrMapUint16Bool *map[uint16]bool - FMapUint32Intf map[uint32]interface{} - FptrMapUint32Intf *map[uint32]interface{} - FMapUint32String map[uint32]string - FptrMapUint32String *map[uint32]string - FMapUint32Uint map[uint32]uint - FptrMapUint32Uint *map[uint32]uint - FMapUint32Uint8 map[uint32]uint8 - FptrMapUint32Uint8 *map[uint32]uint8 - FMapUint32Uint16 map[uint32]uint16 - FptrMapUint32Uint16 *map[uint32]uint16 - FMapUint32Uint32 map[uint32]uint32 - FptrMapUint32Uint32 *map[uint32]uint32 - FMapUint32Uint64 map[uint32]uint64 - FptrMapUint32Uint64 *map[uint32]uint64 - FMapUint32Uintptr map[uint32]uintptr - FptrMapUint32Uintptr *map[uint32]uintptr - FMapUint32Int map[uint32]int - FptrMapUint32Int *map[uint32]int - FMapUint32Int8 map[uint32]int8 - FptrMapUint32Int8 *map[uint32]int8 - FMapUint32Int16 map[uint32]int16 - FptrMapUint32Int16 *map[uint32]int16 - FMapUint32Int32 map[uint32]int32 - FptrMapUint32Int32 *map[uint32]int32 - FMapUint32Int64 map[uint32]int64 - FptrMapUint32Int64 *map[uint32]int64 - FMapUint32Float32 map[uint32]float32 - FptrMapUint32Float32 *map[uint32]float32 - FMapUint32Float64 map[uint32]float64 - FptrMapUint32Float64 *map[uint32]float64 - FMapUint32Bool map[uint32]bool - FptrMapUint32Bool *map[uint32]bool - FMapUint64Intf map[uint64]interface{} - FptrMapUint64Intf *map[uint64]interface{} - FMapUint64String map[uint64]string - FptrMapUint64String *map[uint64]string - FMapUint64Uint map[uint64]uint - FptrMapUint64Uint *map[uint64]uint - FMapUint64Uint8 map[uint64]uint8 - FptrMapUint64Uint8 *map[uint64]uint8 - FMapUint64Uint16 map[uint64]uint16 - FptrMapUint64Uint16 *map[uint64]uint16 - FMapUint64Uint32 map[uint64]uint32 - FptrMapUint64Uint32 *map[uint64]uint32 - FMapUint64Uint64 map[uint64]uint64 - FptrMapUint64Uint64 *map[uint64]uint64 - FMapUint64Uintptr map[uint64]uintptr - FptrMapUint64Uintptr *map[uint64]uintptr - FMapUint64Int map[uint64]int - FptrMapUint64Int *map[uint64]int - FMapUint64Int8 map[uint64]int8 - FptrMapUint64Int8 *map[uint64]int8 - FMapUint64Int16 map[uint64]int16 - FptrMapUint64Int16 *map[uint64]int16 - FMapUint64Int32 map[uint64]int32 - FptrMapUint64Int32 *map[uint64]int32 - FMapUint64Int64 map[uint64]int64 - FptrMapUint64Int64 *map[uint64]int64 - FMapUint64Float32 map[uint64]float32 - FptrMapUint64Float32 *map[uint64]float32 - FMapUint64Float64 map[uint64]float64 - FptrMapUint64Float64 *map[uint64]float64 - FMapUint64Bool map[uint64]bool - FptrMapUint64Bool *map[uint64]bool - FMapUintptrIntf map[uintptr]interface{} - FptrMapUintptrIntf *map[uintptr]interface{} - FMapUintptrString map[uintptr]string - FptrMapUintptrString *map[uintptr]string - FMapUintptrUint map[uintptr]uint - FptrMapUintptrUint *map[uintptr]uint - FMapUintptrUint8 map[uintptr]uint8 - FptrMapUintptrUint8 *map[uintptr]uint8 - FMapUintptrUint16 map[uintptr]uint16 - FptrMapUintptrUint16 *map[uintptr]uint16 - FMapUintptrUint32 map[uintptr]uint32 - FptrMapUintptrUint32 *map[uintptr]uint32 - FMapUintptrUint64 map[uintptr]uint64 - FptrMapUintptrUint64 *map[uintptr]uint64 - FMapUintptrUintptr map[uintptr]uintptr - FptrMapUintptrUintptr *map[uintptr]uintptr - FMapUintptrInt map[uintptr]int - FptrMapUintptrInt *map[uintptr]int - FMapUintptrInt8 map[uintptr]int8 - FptrMapUintptrInt8 *map[uintptr]int8 - FMapUintptrInt16 map[uintptr]int16 - FptrMapUintptrInt16 *map[uintptr]int16 - FMapUintptrInt32 map[uintptr]int32 - FptrMapUintptrInt32 *map[uintptr]int32 - FMapUintptrInt64 map[uintptr]int64 - FptrMapUintptrInt64 *map[uintptr]int64 - FMapUintptrFloat32 map[uintptr]float32 - FptrMapUintptrFloat32 *map[uintptr]float32 - FMapUintptrFloat64 map[uintptr]float64 - FptrMapUintptrFloat64 *map[uintptr]float64 - FMapUintptrBool map[uintptr]bool - FptrMapUintptrBool *map[uintptr]bool - FMapIntIntf map[int]interface{} - FptrMapIntIntf *map[int]interface{} - FMapIntString map[int]string - FptrMapIntString *map[int]string - FMapIntUint map[int]uint - FptrMapIntUint *map[int]uint - FMapIntUint8 map[int]uint8 - FptrMapIntUint8 *map[int]uint8 - FMapIntUint16 map[int]uint16 - FptrMapIntUint16 *map[int]uint16 - FMapIntUint32 map[int]uint32 - FptrMapIntUint32 *map[int]uint32 - FMapIntUint64 map[int]uint64 - FptrMapIntUint64 *map[int]uint64 - FMapIntUintptr map[int]uintptr - FptrMapIntUintptr *map[int]uintptr - FMapIntInt map[int]int - FptrMapIntInt *map[int]int - FMapIntInt8 map[int]int8 - FptrMapIntInt8 *map[int]int8 - FMapIntInt16 map[int]int16 - FptrMapIntInt16 *map[int]int16 - FMapIntInt32 map[int]int32 - FptrMapIntInt32 *map[int]int32 - FMapIntInt64 map[int]int64 - FptrMapIntInt64 *map[int]int64 - FMapIntFloat32 map[int]float32 - FptrMapIntFloat32 *map[int]float32 - FMapIntFloat64 map[int]float64 - FptrMapIntFloat64 *map[int]float64 - FMapIntBool map[int]bool - FptrMapIntBool *map[int]bool - FMapInt8Intf map[int8]interface{} - FptrMapInt8Intf *map[int8]interface{} - FMapInt8String map[int8]string - FptrMapInt8String *map[int8]string - FMapInt8Uint map[int8]uint - FptrMapInt8Uint *map[int8]uint - FMapInt8Uint8 map[int8]uint8 - FptrMapInt8Uint8 *map[int8]uint8 - FMapInt8Uint16 map[int8]uint16 - FptrMapInt8Uint16 *map[int8]uint16 - FMapInt8Uint32 map[int8]uint32 - FptrMapInt8Uint32 *map[int8]uint32 - FMapInt8Uint64 map[int8]uint64 - FptrMapInt8Uint64 *map[int8]uint64 - FMapInt8Uintptr map[int8]uintptr - FptrMapInt8Uintptr *map[int8]uintptr - FMapInt8Int map[int8]int - FptrMapInt8Int *map[int8]int - FMapInt8Int8 map[int8]int8 - FptrMapInt8Int8 *map[int8]int8 - FMapInt8Int16 map[int8]int16 - FptrMapInt8Int16 *map[int8]int16 - FMapInt8Int32 map[int8]int32 - FptrMapInt8Int32 *map[int8]int32 - FMapInt8Int64 map[int8]int64 - FptrMapInt8Int64 *map[int8]int64 - FMapInt8Float32 map[int8]float32 - FptrMapInt8Float32 *map[int8]float32 - FMapInt8Float64 map[int8]float64 - FptrMapInt8Float64 *map[int8]float64 - FMapInt8Bool map[int8]bool - FptrMapInt8Bool *map[int8]bool - FMapInt16Intf map[int16]interface{} - FptrMapInt16Intf *map[int16]interface{} - FMapInt16String map[int16]string - FptrMapInt16String *map[int16]string - FMapInt16Uint map[int16]uint - FptrMapInt16Uint *map[int16]uint - FMapInt16Uint8 map[int16]uint8 - FptrMapInt16Uint8 *map[int16]uint8 - FMapInt16Uint16 map[int16]uint16 - FptrMapInt16Uint16 *map[int16]uint16 - FMapInt16Uint32 map[int16]uint32 - FptrMapInt16Uint32 *map[int16]uint32 - FMapInt16Uint64 map[int16]uint64 - FptrMapInt16Uint64 *map[int16]uint64 - FMapInt16Uintptr map[int16]uintptr - FptrMapInt16Uintptr *map[int16]uintptr - FMapInt16Int map[int16]int - FptrMapInt16Int *map[int16]int - FMapInt16Int8 map[int16]int8 - FptrMapInt16Int8 *map[int16]int8 - FMapInt16Int16 map[int16]int16 - FptrMapInt16Int16 *map[int16]int16 - FMapInt16Int32 map[int16]int32 - FptrMapInt16Int32 *map[int16]int32 - FMapInt16Int64 map[int16]int64 - FptrMapInt16Int64 *map[int16]int64 - FMapInt16Float32 map[int16]float32 - FptrMapInt16Float32 *map[int16]float32 - FMapInt16Float64 map[int16]float64 - FptrMapInt16Float64 *map[int16]float64 - FMapInt16Bool map[int16]bool - FptrMapInt16Bool *map[int16]bool - FMapInt32Intf map[int32]interface{} - FptrMapInt32Intf *map[int32]interface{} - FMapInt32String map[int32]string - FptrMapInt32String *map[int32]string - FMapInt32Uint map[int32]uint - FptrMapInt32Uint *map[int32]uint - FMapInt32Uint8 map[int32]uint8 - FptrMapInt32Uint8 *map[int32]uint8 - FMapInt32Uint16 map[int32]uint16 - FptrMapInt32Uint16 *map[int32]uint16 - FMapInt32Uint32 map[int32]uint32 - FptrMapInt32Uint32 *map[int32]uint32 - FMapInt32Uint64 map[int32]uint64 - FptrMapInt32Uint64 *map[int32]uint64 - FMapInt32Uintptr map[int32]uintptr - FptrMapInt32Uintptr *map[int32]uintptr - FMapInt32Int map[int32]int - FptrMapInt32Int *map[int32]int - FMapInt32Int8 map[int32]int8 - FptrMapInt32Int8 *map[int32]int8 - FMapInt32Int16 map[int32]int16 - FptrMapInt32Int16 *map[int32]int16 - FMapInt32Int32 map[int32]int32 - FptrMapInt32Int32 *map[int32]int32 - FMapInt32Int64 map[int32]int64 - FptrMapInt32Int64 *map[int32]int64 - FMapInt32Float32 map[int32]float32 - FptrMapInt32Float32 *map[int32]float32 - FMapInt32Float64 map[int32]float64 - FptrMapInt32Float64 *map[int32]float64 - FMapInt32Bool map[int32]bool - FptrMapInt32Bool *map[int32]bool - FMapInt64Intf map[int64]interface{} - FptrMapInt64Intf *map[int64]interface{} - FMapInt64String map[int64]string - FptrMapInt64String *map[int64]string - FMapInt64Uint map[int64]uint - FptrMapInt64Uint *map[int64]uint - FMapInt64Uint8 map[int64]uint8 - FptrMapInt64Uint8 *map[int64]uint8 - FMapInt64Uint16 map[int64]uint16 - FptrMapInt64Uint16 *map[int64]uint16 - FMapInt64Uint32 map[int64]uint32 - FptrMapInt64Uint32 *map[int64]uint32 - FMapInt64Uint64 map[int64]uint64 - FptrMapInt64Uint64 *map[int64]uint64 - FMapInt64Uintptr map[int64]uintptr - FptrMapInt64Uintptr *map[int64]uintptr - FMapInt64Int map[int64]int - FptrMapInt64Int *map[int64]int - FMapInt64Int8 map[int64]int8 - FptrMapInt64Int8 *map[int64]int8 - FMapInt64Int16 map[int64]int16 - FptrMapInt64Int16 *map[int64]int16 - FMapInt64Int32 map[int64]int32 - FptrMapInt64Int32 *map[int64]int32 - FMapInt64Int64 map[int64]int64 - FptrMapInt64Int64 *map[int64]int64 - FMapInt64Float32 map[int64]float32 - FptrMapInt64Float32 *map[int64]float32 - FMapInt64Float64 map[int64]float64 - FptrMapInt64Float64 *map[int64]float64 - FMapInt64Bool map[int64]bool - FptrMapInt64Bool *map[int64]bool - FMapBoolIntf map[bool]interface{} - FptrMapBoolIntf *map[bool]interface{} - FMapBoolString map[bool]string - FptrMapBoolString *map[bool]string - FMapBoolUint map[bool]uint - FptrMapBoolUint *map[bool]uint - FMapBoolUint8 map[bool]uint8 - FptrMapBoolUint8 *map[bool]uint8 - FMapBoolUint16 map[bool]uint16 - FptrMapBoolUint16 *map[bool]uint16 - FMapBoolUint32 map[bool]uint32 - FptrMapBoolUint32 *map[bool]uint32 - FMapBoolUint64 map[bool]uint64 - FptrMapBoolUint64 *map[bool]uint64 - FMapBoolUintptr map[bool]uintptr - FptrMapBoolUintptr *map[bool]uintptr - FMapBoolInt map[bool]int - FptrMapBoolInt *map[bool]int - FMapBoolInt8 map[bool]int8 - FptrMapBoolInt8 *map[bool]int8 - FMapBoolInt16 map[bool]int16 - FptrMapBoolInt16 *map[bool]int16 - FMapBoolInt32 map[bool]int32 - FptrMapBoolInt32 *map[bool]int32 - FMapBoolInt64 map[bool]int64 - FptrMapBoolInt64 *map[bool]int64 - FMapBoolFloat32 map[bool]float32 - FptrMapBoolFloat32 *map[bool]float32 - FMapBoolFloat64 map[bool]float64 - FptrMapBoolFloat64 *map[bool]float64 - FMapBoolBool map[bool]bool - FptrMapBoolBool *map[bool]bool -} diff --git a/vendor/github.com/ugorji/go/codec/py_test.go b/vendor/github.com/ugorji/go/codec/py_test.go deleted file mode 100644 index a497cdf30f..0000000000 --- a/vendor/github.com/ugorji/go/codec/py_test.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build x - -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// These tests are used to verify msgpack and cbor implementations against their python libraries. -// If you have the library installed, you can enable the tests back by running: go test -tags=x . -// Look at test.py for how to setup your environment. - -import ( - "testing" -) - -func TestMsgpackPythonGenStreams(t *testing.T) { - doTestPythonGenStreams(t, "msgpack", testMsgpackH) -} - -func TestCborPythonGenStreams(t *testing.T) { - doTestPythonGenStreams(t, "cbor", testCborH) -} - -func TestMsgpackRpcSpecGoClientToPythonSvc(t *testing.T) { - doTestMsgpackRpcSpecGoClientToPythonSvc(t) -} - -func TestMsgpackRpcSpecPythonClientToGoSvc(t *testing.T) { - doTestMsgpackRpcSpecPythonClientToGoSvc(t) -} diff --git a/vendor/github.com/ugorji/go/codec/shared_test.go b/vendor/github.com/ugorji/go/codec/shared_test.go deleted file mode 100644 index 27b621d19e..0000000000 --- a/vendor/github.com/ugorji/go/codec/shared_test.go +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// This file sets up the variables used, including testInitFns. -// Each file should add initialization that should be performed -// after flags are parsed. -// -// init is a multi-step process: -// - setup vars (handled by init functions in each file) -// - parse flags -// - setup derived vars (handled by pre-init registered functions - registered in init function) -// - post init (handled by post-init registered functions - registered in init function) -// This way, no one has to manage carefully control the initialization -// using file names, etc. -// -// Tests which require external dependencies need the -tag=x parameter. -// They should be run as: -// go test -tags=x -run=. -// Benchmarks should also take this parameter, to include the sereal, xdr, etc. -// To run against codecgen, etc, make sure you pass extra parameters. -// Example usage: -// go test "-tags=x codecgen" -bench=. -// -// To fully test everything: -// go test -tags=x -benchtime=100ms -tv -bg -bi -brw -bu -v -run=. -bench=. - -// Handling flags -// codec_test.go will define a set of global flags for testing, including: -// - Use Reset -// - Use IO reader/writer (vs direct bytes) -// - Set Canonical -// - Set InternStrings -// - Use Symbols -// -// This way, we can test them all by running same set of tests with a different -// set of flags. -// -// Following this, all the benchmarks will utilize flags set by codec_test.go -// and will not redefine these "global" flags. - -import ( - "bytes" - "flag" - "sync" -) - -// DO NOT REMOVE - replacement line for go-codec-bench import declaration tag // - -type testHED struct { - H Handle - E *Encoder - D *Decoder -} - -var ( - testNoopH = NoopHandle(8) - testMsgpackH = &MsgpackHandle{} - testBincH = &BincHandle{} - testSimpleH = &SimpleHandle{} - testCborH = &CborHandle{} - testJsonH = &JsonHandle{} - - testHandles []Handle - testPreInitFns []func() - testPostInitFns []func() - - testOnce sync.Once - - testHEDs []testHED -) - -// flag variables used by tests (and bench) -var ( - testVerbose bool - testInitDebug bool - testUseIoEncDec bool - testStructToArray bool - testCanonical bool - testUseReset bool - testWriteNoSymbols bool - testSkipIntf bool - testInternStr bool - testUseMust bool - testCheckCircRef bool - testJsonIndent int - testMaxInitLen int - - testJsonHTMLCharsAsIs bool - testJsonPreferFloat bool -) - -// flag variables used by bench -var ( - benchDoInitBench bool - benchVerify bool - benchUnscientificRes bool = false - benchMapStringKeyOnly bool - //depth of 0 maps to ~400bytes json-encoded string, 1 maps to ~1400 bytes, etc - //For depth>1, we likely trigger stack growth for encoders, making benchmarking unreliable. - benchDepth int - benchInitDebug bool -) - -func init() { - testHEDs = make([]testHED, 0, 32) - testHandles = append(testHandles, - testNoopH, testMsgpackH, testBincH, testSimpleH, - testCborH, testJsonH) - testInitFlags() - benchInitFlags() -} - -func testInitFlags() { - // delete(testDecOpts.ExtFuncs, timeTyp) - flag.BoolVar(&testVerbose, "tv", false, "Test Verbose") - flag.BoolVar(&testInitDebug, "tg", false, "Test Init Debug") - flag.BoolVar(&testUseIoEncDec, "ti", false, "Use IO Reader/Writer for Marshal/Unmarshal") - flag.BoolVar(&testStructToArray, "ts", false, "Set StructToArray option") - flag.BoolVar(&testWriteNoSymbols, "tn", false, "Set NoSymbols option") - flag.BoolVar(&testCanonical, "tc", false, "Set Canonical option") - flag.BoolVar(&testInternStr, "te", false, "Set InternStr option") - flag.BoolVar(&testSkipIntf, "tf", false, "Skip Interfaces") - flag.BoolVar(&testUseReset, "tr", false, "Use Reset") - flag.IntVar(&testJsonIndent, "td", 0, "Use JSON Indent") - flag.IntVar(&testMaxInitLen, "tx", 0, "Max Init Len") - flag.BoolVar(&testUseMust, "tm", true, "Use Must(En|De)code") - flag.BoolVar(&testCheckCircRef, "tl", false, "Use Check Circular Ref") - flag.BoolVar(&testJsonHTMLCharsAsIs, "tas", false, "Set JSON HTMLCharsAsIs") - flag.BoolVar(&testJsonPreferFloat, "tjf", false, "Prefer Float in json") -} - -func benchInitFlags() { - flag.BoolVar(&benchMapStringKeyOnly, "bs", false, "Bench use maps with string keys only") - flag.BoolVar(&benchInitDebug, "bg", false, "Bench Debug") - flag.IntVar(&benchDepth, "bd", 1, "Bench Depth") - flag.BoolVar(&benchDoInitBench, "bi", false, "Run Bench Init") - flag.BoolVar(&benchVerify, "bv", false, "Verify Decoded Value during Benchmark") - flag.BoolVar(&benchUnscientificRes, "bu", false, "Show Unscientific Results during Benchmark") -} - -func testHEDGet(h Handle) *testHED { - for i := range testHEDs { - v := &testHEDs[i] - if v.H == h { - return v - } - } - testHEDs = append(testHEDs, testHED{h, NewEncoder(nil, h), NewDecoder(nil, h)}) - return &testHEDs[len(testHEDs)-1] -} - -func testReinit() { - testOnce = sync.Once{} - testHEDs = nil -} - -func testInitAll() { - // only parse it once. - if !flag.Parsed() { - flag.Parse() - } - for _, f := range testPreInitFns { - f() - } - for _, f := range testPostInitFns { - f() - } -} - -func testCodecEncode(ts interface{}, bsIn []byte, - fn func([]byte) *bytes.Buffer, h Handle) (bs []byte, err error) { - // bs = make([]byte, 0, approxSize) - var e *Encoder - var buf *bytes.Buffer - if testUseReset { - e = testHEDGet(h).E - } else { - e = NewEncoder(nil, h) - } - if testUseIoEncDec { - buf = fn(bsIn) - e.Reset(buf) - } else { - bs = bsIn - e.ResetBytes(&bs) - } - if testUseMust { - e.MustEncode(ts) - } else { - err = e.Encode(ts) - } - if testUseIoEncDec { - bs = buf.Bytes() - } - return -} - -func testCodecDecode(bs []byte, ts interface{}, h Handle) (err error) { - var d *Decoder - var buf *bytes.Reader - if testUseReset { - d = testHEDGet(h).D - } else { - d = NewDecoder(nil, h) - } - if testUseIoEncDec { - buf = bytes.NewReader(bs) - d.Reset(buf) - } else { - d.ResetBytes(bs) - } - if testUseMust { - d.MustDecode(ts) - } else { - err = d.Decode(ts) - } - return -} - -// ----- functions below are used only by benchmarks alone - -func fnBenchmarkByteBuf(bsIn []byte) (buf *bytes.Buffer) { - // var buf bytes.Buffer - // buf.Grow(approxSize) - buf = bytes.NewBuffer(bsIn) - buf.Truncate(0) - return -} - -func benchFnCodecEncode(ts interface{}, bsIn []byte, h Handle) (bs []byte, err error) { - return testCodecEncode(ts, bsIn, fnBenchmarkByteBuf, h) -} - -func benchFnCodecDecode(bs []byte, ts interface{}, h Handle) (err error) { - return testCodecDecode(bs, ts, h) -} diff --git a/vendor/github.com/ugorji/go/codec/test-cbor-goldens.json b/vendor/github.com/ugorji/go/codec/test-cbor-goldens.json deleted file mode 100644 index 9028586711..0000000000 --- a/vendor/github.com/ugorji/go/codec/test-cbor-goldens.json +++ /dev/null @@ -1,639 +0,0 @@ -[ - { - "cbor": "AA==", - "hex": "00", - "roundtrip": true, - "decoded": 0 - }, - { - "cbor": "AQ==", - "hex": "01", - "roundtrip": true, - "decoded": 1 - }, - { - "cbor": "Cg==", - "hex": "0a", - "roundtrip": true, - "decoded": 10 - }, - { - "cbor": "Fw==", - "hex": "17", - "roundtrip": true, - "decoded": 23 - }, - { - "cbor": "GBg=", - "hex": "1818", - "roundtrip": true, - "decoded": 24 - }, - { - "cbor": "GBk=", - "hex": "1819", - "roundtrip": true, - "decoded": 25 - }, - { - "cbor": "GGQ=", - "hex": "1864", - "roundtrip": true, - "decoded": 100 - }, - { - "cbor": "GQPo", - "hex": "1903e8", - "roundtrip": true, - "decoded": 1000 - }, - { - "cbor": "GgAPQkA=", - "hex": "1a000f4240", - "roundtrip": true, - "decoded": 1000000 - }, - { - "cbor": "GwAAAOjUpRAA", - "hex": "1b000000e8d4a51000", - "roundtrip": true, - "decoded": 1000000000000 - }, - { - "cbor": "G///////////", - "hex": "1bffffffffffffffff", - "roundtrip": true, - "decoded": 18446744073709551615 - }, - { - "cbor": "wkkBAAAAAAAAAAA=", - "hex": "c249010000000000000000", - "roundtrip": true, - "decoded": 18446744073709551616 - }, - { - "cbor": "O///////////", - "hex": "3bffffffffffffffff", - "roundtrip": true, - "decoded": -18446744073709551616, - "skip": true - }, - { - "cbor": "w0kBAAAAAAAAAAA=", - "hex": "c349010000000000000000", - "roundtrip": true, - "decoded": -18446744073709551617 - }, - { - "cbor": "IA==", - "hex": "20", - "roundtrip": true, - "decoded": -1 - }, - { - "cbor": "KQ==", - "hex": "29", - "roundtrip": true, - "decoded": -10 - }, - { - "cbor": "OGM=", - "hex": "3863", - "roundtrip": true, - "decoded": -100 - }, - { - "cbor": "OQPn", - "hex": "3903e7", - "roundtrip": true, - "decoded": -1000 - }, - { - "cbor": "+QAA", - "hex": "f90000", - "roundtrip": true, - "decoded": 0.0 - }, - { - "cbor": "+YAA", - "hex": "f98000", - "roundtrip": true, - "decoded": -0.0 - }, - { - "cbor": "+TwA", - "hex": "f93c00", - "roundtrip": true, - "decoded": 1.0 - }, - { - "cbor": "+z/xmZmZmZma", - "hex": "fb3ff199999999999a", - "roundtrip": true, - "decoded": 1.1 - }, - { - "cbor": "+T4A", - "hex": "f93e00", - "roundtrip": true, - "decoded": 1.5 - }, - { - "cbor": "+Xv/", - "hex": "f97bff", - "roundtrip": true, - "decoded": 65504.0 - }, - { - "cbor": "+kfDUAA=", - "hex": "fa47c35000", - "roundtrip": true, - "decoded": 100000.0 - }, - { - "cbor": "+n9///8=", - "hex": "fa7f7fffff", - "roundtrip": true, - "decoded": 3.4028234663852886e+38 - }, - { - "cbor": "+3435DyIAHWc", - "hex": "fb7e37e43c8800759c", - "roundtrip": true, - "decoded": 1.0e+300 - }, - { - "cbor": "+QAB", - "hex": "f90001", - "roundtrip": true, - "decoded": 5.960464477539063e-08 - }, - { - "cbor": "+QQA", - "hex": "f90400", - "roundtrip": true, - "decoded": 6.103515625e-05 - }, - { - "cbor": "+cQA", - "hex": "f9c400", - "roundtrip": true, - "decoded": -4.0 - }, - { - "cbor": "+8AQZmZmZmZm", - "hex": "fbc010666666666666", - "roundtrip": true, - "decoded": -4.1 - }, - { - "cbor": "+XwA", - "hex": "f97c00", - "roundtrip": true, - "diagnostic": "Infinity" - }, - { - "cbor": "+X4A", - "hex": "f97e00", - "roundtrip": true, - "diagnostic": "NaN" - }, - { - "cbor": "+fwA", - "hex": "f9fc00", - "roundtrip": true, - "diagnostic": "-Infinity" - }, - { - "cbor": "+n+AAAA=", - "hex": "fa7f800000", - "roundtrip": false, - "diagnostic": "Infinity" - }, - { - "cbor": "+n/AAAA=", - "hex": "fa7fc00000", - "roundtrip": false, - "diagnostic": "NaN" - }, - { - "cbor": "+v+AAAA=", - "hex": "faff800000", - "roundtrip": false, - "diagnostic": "-Infinity" - }, - { - "cbor": "+3/wAAAAAAAA", - "hex": "fb7ff0000000000000", - "roundtrip": false, - "diagnostic": "Infinity" - }, - { - "cbor": "+3/4AAAAAAAA", - "hex": "fb7ff8000000000000", - "roundtrip": false, - "diagnostic": "NaN" - }, - { - "cbor": "+//wAAAAAAAA", - "hex": "fbfff0000000000000", - "roundtrip": false, - "diagnostic": "-Infinity" - }, - { - "cbor": "9A==", - "hex": "f4", - "roundtrip": true, - "decoded": false - }, - { - "cbor": "9Q==", - "hex": "f5", - "roundtrip": true, - "decoded": true - }, - { - "cbor": "9g==", - "hex": "f6", - "roundtrip": true, - "decoded": null - }, - { - "cbor": "9w==", - "hex": "f7", - "roundtrip": true, - "diagnostic": "undefined" - }, - { - "cbor": "8A==", - "hex": "f0", - "roundtrip": true, - "diagnostic": "simple(16)" - }, - { - "cbor": "+Bg=", - "hex": "f818", - "roundtrip": true, - "diagnostic": "simple(24)" - }, - { - "cbor": "+P8=", - "hex": "f8ff", - "roundtrip": true, - "diagnostic": "simple(255)" - }, - { - "cbor": "wHQyMDEzLTAzLTIxVDIwOjA0OjAwWg==", - "hex": "c074323031332d30332d32315432303a30343a30305a", - "roundtrip": true, - "diagnostic": "0(\"2013-03-21T20:04:00Z\")" - }, - { - "cbor": "wRpRS2ew", - "hex": "c11a514b67b0", - "roundtrip": true, - "diagnostic": "1(1363896240)" - }, - { - "cbor": "wftB1FLZ7CAAAA==", - "hex": "c1fb41d452d9ec200000", - "roundtrip": true, - "diagnostic": "1(1363896240.5)" - }, - { - "cbor": "10QBAgME", - "hex": "d74401020304", - "roundtrip": true, - "diagnostic": "23(h'01020304')" - }, - { - "cbor": "2BhFZElFVEY=", - "hex": "d818456449455446", - "roundtrip": true, - "diagnostic": "24(h'6449455446')" - }, - { - "cbor": "2CB2aHR0cDovL3d3dy5leGFtcGxlLmNvbQ==", - "hex": "d82076687474703a2f2f7777772e6578616d706c652e636f6d", - "roundtrip": true, - "diagnostic": "32(\"http://www.example.com\")" - }, - { - "cbor": "QA==", - "hex": "40", - "roundtrip": true, - "diagnostic": "h''" - }, - { - "cbor": "RAECAwQ=", - "hex": "4401020304", - "roundtrip": true, - "diagnostic": "h'01020304'" - }, - { - "cbor": "YA==", - "hex": "60", - "roundtrip": true, - "decoded": "" - }, - { - "cbor": "YWE=", - "hex": "6161", - "roundtrip": true, - "decoded": "a" - }, - { - "cbor": "ZElFVEY=", - "hex": "6449455446", - "roundtrip": true, - "decoded": "IETF" - }, - { - "cbor": "YiJc", - "hex": "62225c", - "roundtrip": true, - "decoded": "\"\\" - }, - { - "cbor": "YsO8", - "hex": "62c3bc", - "roundtrip": true, - "decoded": "ü" - }, - { - "cbor": "Y+awtA==", - "hex": "63e6b0b4", - "roundtrip": true, - "decoded": "水" - }, - { - "cbor": "ZPCQhZE=", - "hex": "64f0908591", - "roundtrip": true, - "decoded": "𐅑" - }, - { - "cbor": "gA==", - "hex": "80", - "roundtrip": true, - "decoded": [ - - ] - }, - { - "cbor": "gwECAw==", - "hex": "83010203", - "roundtrip": true, - "decoded": [ - 1, - 2, - 3 - ] - }, - { - "cbor": "gwGCAgOCBAU=", - "hex": "8301820203820405", - "roundtrip": true, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "mBkBAgMEBQYHCAkKCwwNDg8QERITFBUWFxgYGBk=", - "hex": "98190102030405060708090a0b0c0d0e0f101112131415161718181819", - "roundtrip": true, - "decoded": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ] - }, - { - "cbor": "oA==", - "hex": "a0", - "roundtrip": true, - "decoded": { - } - }, - { - "cbor": "ogECAwQ=", - "hex": "a201020304", - "roundtrip": true, - "skip": true, - "diagnostic": "{1: 2, 3: 4}" - }, - { - "cbor": "omFhAWFiggID", - "hex": "a26161016162820203", - "roundtrip": true, - "decoded": { - "a": 1, - "b": [ - 2, - 3 - ] - } - }, - { - "cbor": "gmFhoWFiYWM=", - "hex": "826161a161626163", - "roundtrip": true, - "decoded": [ - "a", - { - "b": "c" - } - ] - }, - { - "cbor": "pWFhYUFhYmFCYWNhQ2FkYURhZWFF", - "hex": "a56161614161626142616361436164614461656145", - "roundtrip": true, - "decoded": { - "a": "A", - "b": "B", - "c": "C", - "d": "D", - "e": "E" - } - }, - { - "cbor": "X0IBAkMDBAX/", - "hex": "5f42010243030405ff", - "roundtrip": false, - "skip": true, - "diagnostic": "(_ h'0102', h'030405')" - }, - { - "cbor": "f2VzdHJlYWRtaW5n/w==", - "hex": "7f657374726561646d696e67ff", - "roundtrip": false, - "decoded": "streaming" - }, - { - "cbor": "n/8=", - "hex": "9fff", - "roundtrip": false, - "decoded": [ - - ] - }, - { - "cbor": "nwGCAgOfBAX//w==", - "hex": "9f018202039f0405ffff", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "nwGCAgOCBAX/", - "hex": "9f01820203820405ff", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "gwGCAgOfBAX/", - "hex": "83018202039f0405ff", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "gwGfAgP/ggQF", - "hex": "83019f0203ff820405", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "nwECAwQFBgcICQoLDA0ODxAREhMUFRYXGBgYGf8=", - "hex": "9f0102030405060708090a0b0c0d0e0f101112131415161718181819ff", - "roundtrip": false, - "decoded": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ] - }, - { - "cbor": "v2FhAWFinwID//8=", - "hex": "bf61610161629f0203ffff", - "roundtrip": false, - "decoded": { - "a": 1, - "b": [ - 2, - 3 - ] - } - }, - { - "cbor": "gmFhv2FiYWP/", - "hex": "826161bf61626163ff", - "roundtrip": false, - "decoded": [ - "a", - { - "b": "c" - } - ] - }, - { - "cbor": "v2NGdW71Y0FtdCH/", - "hex": "bf6346756ef563416d7421ff", - "roundtrip": false, - "decoded": { - "Fun": true, - "Amt": -2 - } - } -] diff --git a/vendor/github.com/ugorji/go/codec/test.py b/vendor/github.com/ugorji/go/codec/test.py deleted file mode 100755 index 800376f684..0000000000 --- a/vendor/github.com/ugorji/go/codec/test.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python - -# This will create golden files in a directory passed to it. -# A Test calls this internally to create the golden files -# So it can process them (so we don't have to checkin the files). - -# Ensure msgpack-python and cbor are installed first, using: -# sudo apt-get install python-dev -# sudo apt-get install python-pip -# pip install --user msgpack-python msgpack-rpc-python cbor - -# Ensure all "string" keys are utf strings (else encoded as bytes) - -import cbor, msgpack, msgpackrpc, sys, os, threading - -def get_test_data_list(): - # get list with all primitive types, and a combo type - l0 = [ - -8, - -1616, - -32323232, - -6464646464646464, - 192, - 1616, - 32323232, - 6464646464646464, - 192, - -3232.0, - -6464646464.0, - 3232.0, - 6464.0, - 6464646464.0, - False, - True, - u"null", - None, - u"some&day>some 0 - if stopTimeSec > 0: - def myStopRpcServer(): - server.stop() - t = threading.Timer(stopTimeSec, myStopRpcServer) - t.start() - server.start() - -def doRpcClientToPythonSvc(port): - address = msgpackrpc.Address('127.0.0.1', port) - client = msgpackrpc.Client(address, unpack_encoding='utf-8') - print client.call("Echo123", "A1", "B2", "C3") - print client.call("EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"}) - -def doRpcClientToGoSvc(port): - # print ">>>> port: ", port, " <<<<<" - address = msgpackrpc.Address('127.0.0.1', port) - client = msgpackrpc.Client(address, unpack_encoding='utf-8') - print client.call("TestRpcInt.Echo123", ["A1", "B2", "C3"]) - print client.call("TestRpcInt.EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"}) - -def doMain(args): - if len(args) == 2 and args[0] == "testdata": - build_test_data(args[1]) - elif len(args) == 3 and args[0] == "rpc-server": - doRpcServer(int(args[1]), int(args[2])) - elif len(args) == 2 and args[0] == "rpc-client-python-service": - doRpcClientToPythonSvc(int(args[1])) - elif len(args) == 2 and args[0] == "rpc-client-go-service": - doRpcClientToGoSvc(int(args[1])) - else: - print("Usage: test.py " + - "[testdata|rpc-server|rpc-client-python-service|rpc-client-go-service] ...") - -if __name__ == "__main__": - doMain(sys.argv[1:]) - diff --git a/vendor/github.com/ugorji/go/codec/values_test.go b/vendor/github.com/ugorji/go/codec/values_test.go deleted file mode 100644 index 2c0d4b030b..0000000000 --- a/vendor/github.com/ugorji/go/codec/values_test.go +++ /dev/null @@ -1,214 +0,0 @@ -/* // +build testing */ - -// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// This file contains values used by tests and benchmarks. -// JSON/BSON do not like maps with keys that are not strings, -// so we only use maps with string keys here. - -import ( - "math" - "time" -) - -var testStrucTime = time.Date(2012, 2, 2, 2, 2, 2, 2000, time.UTC).UTC() - -type AnonInTestStruc struct { - AS string - AI64 int64 - AI16 int16 - AUi64 uint64 - ASslice []string - AI64slice []int64 - AF64slice []float64 - // AMI32U32 map[int32]uint32 - // AMU32F64 map[uint32]float64 // json/bson do not like it - AMSU16 map[string]uint16 -} - -type AnonInTestStrucIntf struct { - Islice []interface{} - Ms map[string]interface{} - Nintf interface{} //don't set this, so we can test for nil - T time.Time -} - -type TestStruc struct { - _struct struct{} `codec:",omitempty"` //set omitempty for every field - - S string - I64 int64 - I16 int16 - Ui64 uint64 - Ui8 uint8 - B bool - By uint8 // byte: msgp doesn't like byte - - Sslice []string - I64slice []int64 - I16slice []int16 - Ui64slice []uint64 - Ui8slice []uint8 - Bslice []bool - Byslice []byte - - Iptrslice []*int64 - - // TODO: test these separately, specifically for reflection and codecgen. - // Unfortunately, ffjson doesn't support these. Its compilation even fails. - // Ui64array [4]uint64 - // Ui64slicearray [][4]uint64 - - AnonInTestStruc - - //M map[interface{}]interface{} `json:"-",bson:"-"` - Msi64 map[string]int64 - - // make this a ptr, so that it could be set or not. - // for comparison (e.g. with msgp), give it a struct tag (so it is not inlined), - // make this one omitempty (so it is included if nil). - *AnonInTestStrucIntf `codec:",omitempty"` - - 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 - Mtsptr map[string]*TestStruc - Mts map[string]TestStruc - Its []*TestStruc - Nteststruc *TestStruc -} - -// small struct for testing that codecgen works for unexported types -type tLowerFirstLetter struct { - I int - u uint64 - S string - b []byte -} - -func newTestStruc(depth int, bench bool, useInterface, useStringKeyOnly bool) (ts *TestStruc) { - var i64a, i64b, i64c, i64d int64 = 64, 6464, 646464, 64646464 - - ts = &TestStruc{ - S: "some string", - I64: math.MaxInt64 * 2 / 3, // 64, - I16: 1616, - Ui64: uint64(int64(math.MaxInt64 * 2 / 3)), // 64, //don't use MaxUint64, as bson can't write it - Ui8: 160, - B: true, - By: 5, - - Sslice: []string{"one", "two", "three"}, - I64slice: []int64{1111, 2222, 3333}, - I16slice: []int16{44, 55, 66}, - Ui64slice: []uint64{12121212, 34343434, 56565656}, - Ui8slice: []uint8{210, 211, 212}, - Bslice: []bool{true, false, true, false}, - Byslice: []byte{13, 14, 15}, - - Msi64: map[string]int64{ - "one": 1, - "two": 2, - }, - AnonInTestStruc: AnonInTestStruc{ - // There's more leeway in altering this. - AS: "A-String", - AI64: -64646464, - AI16: 1616, - AUi64: 64646464, - // (U+1D11E)G-clef character may be represented in json as "\uD834\uDD1E". - // single reverse solidus character may be represented in json as "\u005C". - // include these in ASslice below. - ASslice: []string{"Aone", "Atwo", "Athree", - "Afour.reverse_solidus.\u005c", "Afive.Gclef.\U0001d11E"}, - AI64slice: []int64{1, -22, 333, -4444, 55555, -666666}, - AMSU16: map[string]uint16{"1": 1, "22": 2, "333": 3, "4444": 4}, - AF64slice: []float64{ - 11.11e-11, -11.11e+11, - 2.222E+12, -2.222E-12, - -555.55E-5, 555.55E+5, - 666.66E-6, -666.66E+6, - 7777.7777E-7, -7777.7777E-7, - -8888.8888E+8, 8888.8888E+8, - -99999.9999E+9, 99999.9999E+9, - // these below are hairy enough to need strconv.ParseFloat - 33.33E-33, -33.33E+33, - 44.44e+44, -44.44e-44, - }, - }, - } - if useInterface { - ts.AnonInTestStrucIntf = &AnonInTestStrucIntf{ - Islice: []interface{}{"true", true, "no", false, uint64(288), float64(0.4)}, - Ms: map[string]interface{}{ - "true": "true", - "int64(9)": false, - }, - T: testStrucTime, - } - } - - //For benchmarks, some things will not work. - if !bench { - //json and bson require string keys in maps - //ts.M = map[interface{}]interface{}{ - // true: "true", - // int8(9): false, - //} - //gob cannot encode nil in element in array (encodeArray: nil element) - ts.Iptrslice = []*int64{nil, &i64a, nil, &i64b, nil, &i64c, nil, &i64d, nil} - // ts.Iptrslice = nil - } - if !useStringKeyOnly { - // ts.AnonInTestStruc.AMU32F64 = map[uint32]float64{1: 1, 2: 2, 3: 3} // Json/Bson barf - } - if depth > 0 { - depth-- - if ts.Mtsptr == nil { - ts.Mtsptr = make(map[string]*TestStruc) - } - if ts.Mts == nil { - ts.Mts = make(map[string]TestStruc) - } - ts.Mtsptr["0"] = newTestStruc(depth, bench, useInterface, useStringKeyOnly) - ts.Mts["0"] = *(ts.Mtsptr["0"]) - ts.Its = append(ts.Its, ts.Mtsptr["0"]) - } - return -} - -// Some other types - -type Sstring string -type Bbool bool -type Sstructsmall struct { - A int -} - -type Sstructbig struct { - A int - B bool - c string - // Sval Sstruct - Ssmallptr *Sstructsmall - Ssmall *Sstructsmall - Sptr *Sstructbig -} - -type SstructbigMapBySlice struct { - _struct struct{} `codec:",toarray"` - A int - B bool - c string - // Sval Sstruct - Ssmallptr *Sstructsmall - Ssmall *Sstructsmall - Sptr *Sstructbig -} - -type Sinterface interface { - Noop() -} diff --git a/vendor/github.com/ugorji/go/codec/z_all_test.go b/vendor/github.com/ugorji/go/codec/z_all_test.go deleted file mode 100644 index 364cbd7e6f..0000000000 --- a/vendor/github.com/ugorji/go/codec/z_all_test.go +++ /dev/null @@ -1,135 +0,0 @@ -// +build alltests -// +build go1.7 - -package codec - -// Run this using: -// go test -tags=alltests -run=Suite -coverprofile=cov.out -// go tool cover -html=cov.out -// -// Because build tags are a build time parameter, we will have to test out the -// different tags separately. -// Tags: x codecgen safe appengine notfastpath -// -// These tags should be added to alltests, e.g. -// go test '-tags=alltests x codecgen' -run=Suite -coverprofile=cov.out -// -// To run all tests before submitting code, run: -// a=( "" "safe" "codecgen" "notfastpath" "codecgen notfastpath" "codecgen safe" "safe notfastpath" ) -// for i in "${a[@]}"; do echo ">>>> TAGS: $i"; go test "-tags=alltests $i" -run=Suite; done -// -// This only works on go1.7 and above. This is when subtests and suites were supported. - -import "testing" - -// func TestMain(m *testing.M) { -// println("calling TestMain") -// // set some parameters -// exitcode := m.Run() -// os.Exit(exitcode) -// } - -func testSuite(t *testing.T, f func(t *testing.T)) { - // find . -name "*_test.go" | xargs grep -e 'flag.' | cut -d '&' -f 2 | cut -d ',' -f 1 | grep -e '^test' - // Disregard the following: testVerbose, testInitDebug, testSkipIntf, testJsonIndent (Need a test for it) - - testReinit() // so flag.Parse() is called first, and never called again - - testUseMust = false - testCanonical = false - testUseMust = false - testInternStr = false - testUseIoEncDec = false - testStructToArray = false - testWriteNoSymbols = false - testCheckCircRef = false - testJsonHTMLCharsAsIs = false - testUseReset = false - testMaxInitLen = 0 - testJsonIndent = 0 - testReinit() - t.Run("optionsFalse", f) - - testMaxInitLen = 10 - testJsonIndent = 8 - testReinit() - t.Run("initLen10-jsonSpaces", f) - - testReinit() - testMaxInitLen = 10 - testJsonIndent = -1 - testReinit() - t.Run("initLen10-jsonTabs", f) - - testCanonical = true - testUseMust = true - testInternStr = true - testUseIoEncDec = true - testStructToArray = true - testWriteNoSymbols = true - testCheckCircRef = true - testJsonHTMLCharsAsIs = true - testUseReset = true - testReinit() - t.Run("optionsTrue", f) -} - -/* -z='codec_test.go' -find . -name "$z" | xargs grep -e '^func Test' | \ - cut -d '(' -f 1 | cut -d ' ' -f 2 | \ - while read f; do echo "t.Run(\"$f\", $f)"; done -*/ - -func testCodecGroup(t *testing.T) { - // println("running testcodecsuite") - // - t.Run("TestBincCodecsTable", TestBincCodecsTable) - t.Run("TestBincCodecsMisc", TestBincCodecsMisc) - t.Run("TestBincCodecsEmbeddedPointer", TestBincCodecsEmbeddedPointer) - t.Run("TestBincStdEncIntf", TestBincStdEncIntf) - t.Run("TestBincMammoth", TestBincMammoth) - t.Run("TestSimpleCodecsTable", TestSimpleCodecsTable) - t.Run("TestSimpleCodecsMisc", TestSimpleCodecsMisc) - t.Run("TestSimpleCodecsEmbeddedPointer", TestSimpleCodecsEmbeddedPointer) - t.Run("TestSimpleStdEncIntf", TestSimpleStdEncIntf) - t.Run("TestSimpleMammoth", TestSimpleMammoth) - t.Run("TestMsgpackCodecsTable", TestMsgpackCodecsTable) - t.Run("TestMsgpackCodecsMisc", TestMsgpackCodecsMisc) - t.Run("TestMsgpackCodecsEmbeddedPointer", TestMsgpackCodecsEmbeddedPointer) - t.Run("TestMsgpackStdEncIntf", TestMsgpackStdEncIntf) - t.Run("TestMsgpackMammoth", TestMsgpackMammoth) - t.Run("TestCborCodecsTable", TestCborCodecsTable) - t.Run("TestCborCodecsMisc", TestCborCodecsMisc) - t.Run("TestCborCodecsEmbeddedPointer", TestCborCodecsEmbeddedPointer) - t.Run("TestCborMapEncodeForCanonical", TestCborMapEncodeForCanonical) - t.Run("TestCborCodecChan", TestCborCodecChan) - t.Run("TestCborStdEncIntf", TestCborStdEncIntf) - t.Run("TestCborMammoth", TestCborMammoth) - t.Run("TestJsonCodecsTable", TestJsonCodecsTable) - t.Run("TestJsonCodecsMisc", TestJsonCodecsMisc) - t.Run("TestJsonCodecsEmbeddedPointer", TestJsonCodecsEmbeddedPointer) - t.Run("TestJsonCodecChan", TestJsonCodecChan) - t.Run("TestJsonStdEncIntf", TestJsonStdEncIntf) - t.Run("TestJsonMammoth", TestJsonMammoth) - t.Run("TestJsonRaw", TestJsonRaw) - t.Run("TestBincRaw", TestBincRaw) - t.Run("TestMsgpackRaw", TestMsgpackRaw) - t.Run("TestSimpleRaw", TestSimpleRaw) - t.Run("TestCborRaw", TestCborRaw) - t.Run("TestAllEncCircularRef", TestAllEncCircularRef) - t.Run("TestAllAnonCycle", TestAllAnonCycle) - t.Run("TestBincRpcGo", TestBincRpcGo) - t.Run("TestSimpleRpcGo", TestSimpleRpcGo) - t.Run("TestMsgpackRpcGo", TestMsgpackRpcGo) - t.Run("TestCborRpcGo", TestCborRpcGo) - t.Run("TestJsonRpcGo", TestJsonRpcGo) - t.Run("TestMsgpackRpcSpec", TestMsgpackRpcSpec) - t.Run("TestBincUnderlyingType", TestBincUnderlyingType) - t.Run("TestJsonLargeInteger", TestJsonLargeInteger) - t.Run("TestJsonDecodeNonStringScalarInStringContext", TestJsonDecodeNonStringScalarInStringContext) - t.Run("TestJsonEncodeIndent", TestJsonEncodeIndent) - // -} - -func TestCodecSuite(t *testing.T) { testSuite(t, testCodecGroup) } diff --git a/vendor/manifest b/vendor/manifest index 1b1ba63d34..2309f7138b 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -1907,10 +1907,11 @@ { "importpath": "github.com/ugorji/go/codec", "repository": "https://github.com/ugorji/go", - "vcs": "", - "revision": "c062049c1793b01a3cc3fe786108edabbaf7756b", - "branch": "master", - "path": "/codec" + "vcs": "git", + "revision": "54210f4e076c57f351166f0ed60e67d3fca57a36", + "branch": "HEAD", + "path": "/codec", + "notests": true }, { "importpath": "github.com/urfave/negroni",