From 66e8faa858155c283fa110456a1d6c1f68d1a098 Mon Sep 17 00:00:00 2001 From: Julien Rische Date: Fri, 29 Apr 2022 19:26:42 +0200 Subject: [PATCH] Fix large literals type inference on 32 bits Some tests are failing because some large literal integers are meant to be stored on 64 bits, but are stored on 32 on 32 bits architectures. This causes the value to overflow. This commit fixes this issue by using explicit int64 typing. Signed-off-by: Julien Rische --- decode_test.go | 6 +++--- encode_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/decode_test.go b/decode_test.go index fb13b9a..555bcaa 100644 --- a/decode_test.go +++ b/decode_test.go @@ -89,7 +89,7 @@ func TestDecoder(t *testing.T) { }, { "v: -0b1000000000000000000000000000000000000000000000000000000000000000", - map[string]interface{}{"v": -9223372036854775808}, + map[string]interface{}{"v": int64(-9223372036854775808)}, }, { "v: 0xA", @@ -109,7 +109,7 @@ func TestDecoder(t *testing.T) { }, { "v: 4294967296\n", - map[string]int{"v": 4294967296}, + map[string]int64{"v": int64(4294967296)}, }, { "v: 0.1\n", @@ -200,7 +200,7 @@ func TestDecoder(t *testing.T) { map[string]uint{"v": 42}, }, { "v: 4294967296", - map[string]uint64{"v": 4294967296}, + map[string]uint64{"v": uint64(4294967296)}, }, // int diff --git a/encode_test.go b/encode_test.go index 0a6f1fe..2edb9a2 100644 --- a/encode_test.go +++ b/encode_test.go @@ -65,7 +65,7 @@ func TestEncoder(t *testing.T) { }, { "v: 4294967296\n", - map[string]int{"v": 4294967296}, + map[string]int64{"v": int64(4294967296)}, nil, }, {