From ca9b7c4e3503b269897cf222443fb7ff7cc25640 Mon Sep 17 00:00:00 2001 From: Emil Tullstedt Date: Fri, 6 Dec 2019 14:15:10 +0100 Subject: [PATCH 1/3] explicitly use int64 for large test constants To ensure goavro can compile on 32-bit systems --- binary_test.go | 2 +- integer_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/binary_test.go b/binary_test.go index b1152df..45f12cf 100644 --- a/binary_test.go +++ b/binary_test.go @@ -39,7 +39,7 @@ func init() { panic(err) } - mostNegativeBlockCount, err = c.BinaryFromNative(nil, math.MinInt64) + mostNegativeBlockCount, err = c.BinaryFromNative(nil, int64(math.MinInt64)) if err != nil { panic(err) } diff --git a/integer_test.go b/integer_test.go index ba54933..22b6ef4 100644 --- a/integer_test.go +++ b/integer_test.go @@ -53,24 +53,24 @@ func TestSchemaPrimitiveCodecLong(t *testing.T) { func TestPrimitiveLongBinary(t *testing.T) { testBinaryEncodeFailBadDatumType(t, `"long"`, "some string") testBinaryDecodeFailShortBuffer(t, `"long"`, []byte("\xff\xff\xff\xff")) - testBinaryCodecPass(t, `"long"`, (1<<63)-1, []byte{0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1}) - testBinaryCodecPass(t, `"long"`, -(1 << 63), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1}) + testBinaryCodecPass(t, `"long"`, int64((1<<63)-1), []byte{0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1}) + testBinaryCodecPass(t, `"long"`, int64(-(1 << 63)), []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1}) testBinaryCodecPass(t, `"long"`, -2147483648, []byte("\xff\xff\xff\xff\x0f")) testBinaryCodecPass(t, `"long"`, -3, []byte("\x05")) testBinaryCodecPass(t, `"long"`, -65, []byte("\x81\x01")) testBinaryCodecPass(t, `"long"`, 0, []byte("\x00")) testBinaryCodecPass(t, `"long"`, 1082196484, []byte("\x88\x88\x88\x88\x08")) - testBinaryCodecPass(t, `"long"`, 1359702038045356208, []byte{0xe0, 0xc2, 0x8b, 0xa1, 0x96, 0xf3, 0xd0, 0xde, 0x25}) - testBinaryCodecPass(t, `"long"`, 138521149956, []byte("\x88\x88\x88\x88\x88\x08")) - testBinaryCodecPass(t, `"long"`, 17730707194372, []byte("\x88\x88\x88\x88\x88\x88\x08")) + testBinaryCodecPass(t, `"long"`, int64(1359702038045356208), []byte{0xe0, 0xc2, 0x8b, 0xa1, 0x96, 0xf3, 0xd0, 0xde, 0x25}) + testBinaryCodecPass(t, `"long"`, int64(138521149956), []byte("\x88\x88\x88\x88\x88\x08")) + testBinaryCodecPass(t, `"long"`, int64(17730707194372), []byte("\x88\x88\x88\x88\x88\x88\x08")) testBinaryCodecPass(t, `"long"`, 2147483647, []byte("\xfe\xff\xff\xff\x0f")) - testBinaryCodecPass(t, `"long"`, 2269530520879620, []byte("\x88\x88\x88\x88\x88\x88\x88\x08")) + testBinaryCodecPass(t, `"long"`, int64(2269530520879620), []byte("\x88\x88\x88\x88\x88\x88\x88\x08")) testBinaryCodecPass(t, `"long"`, 3, []byte("\x06")) - testBinaryCodecPass(t, `"long"`, 5959107741628848600, []byte{0xb0, 0xe7, 0x8a, 0xe1, 0xe2, 0xba, 0x80, 0xb3, 0xa5, 0x1}) + testBinaryCodecPass(t, `"long"`, int64(5959107741628848600), []byte{0xb0, 0xe7, 0x8a, 0xe1, 0xe2, 0xba, 0x80, 0xb3, 0xa5, 0x1}) testBinaryCodecPass(t, `"long"`, 64, []byte("\x80\x01")) // https://github.com/linkedin/goavro/issues/49 - testBinaryCodecPass(t, `"long"`, -5513458701470791632, []byte("\x9f\xdf\x9f\x8f\xc7\xde\xde\x83\x99\x01")) + testBinaryCodecPass(t, `"long"`, int64(-5513458701470791632), []byte("\x9f\xdf\x9f\x8f\xc7\xde\xde\x83\x99\x01")) } func TestPrimitiveLongText(t *testing.T) { From 4a4826cd4741c51f913e9e3e58d4af1711b2d108 Mon Sep 17 00:00:00 2001 From: Marco Pacini Date: Thu, 26 Mar 2020 15:08:48 +0100 Subject: [PATCH 2/3] Add key value to error message --- map.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map.go b/map.go index ade7076..b1fc088 100644 --- a/map.go +++ b/map.go @@ -204,7 +204,7 @@ func genericMapTextDecoder(buf []byte, defaultCodec *Codec, codecFromKey map[str } value, buf, err = fieldCodec.nativeFromTextual(buf) if err != nil { - return nil, nil, err + return nil, nil, fmt.Errorf("%s for key: %q", err.Error(), key) } // set map value for key mapValues[key] = value From 58a83ea1539a0c8c3946781abac4103abac92535 Mon Sep 17 00:00:00 2001 From: "Karrick S. McDermott" Date: Thu, 25 Jun 2020 13:30:13 -0400 Subject: [PATCH 3/3] simplify error statement --- map.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map.go b/map.go index b1fc088..8f50137 100644 --- a/map.go +++ b/map.go @@ -204,7 +204,7 @@ func genericMapTextDecoder(buf []byte, defaultCodec *Codec, codecFromKey map[str } value, buf, err = fieldCodec.nativeFromTextual(buf) if err != nil { - return nil, nil, fmt.Errorf("%s for key: %q", err.Error(), key) + return nil, nil, fmt.Errorf("%s for key: %q", err, key) } // set map value for key mapValues[key] = value