Browse Source

codec: support tests in 32-bit OS

Use explicit type (e.g. int64, uint64) when dealing
with potentially extreme 64-bit constant values.

Fixes #162
Ugorji Nwoke 9 years ago
parent
commit
4e994e11d3
1 changed files with 7 additions and 5 deletions
  1. 7 5
      codec/codec_test.go

+ 7 - 5
codec/codec_test.go

@@ -1090,11 +1090,13 @@ func doTestJsonLargeInteger(t *testing.T, v interface{}, ias uint8) {
 	case 'L':
 	case 'L':
 		switch v2 := v.(type) {
 		switch v2 := v.(type) {
 		case int:
 		case int:
-			if v2 > 1<<53 || (v2 < 0 && -v2 > 1<<53) {
+			v2n := int64(v2) // done to work with 32-bit OS
+			if v2n > 1<<53 || (v2n < 0 && -v2n > 1<<53) {
 				fnStrChk()
 				fnStrChk()
 			}
 			}
 		case uint:
 		case uint:
-			if v2 > 1<<53 {
+			v2n := uint64(v2) // done to work with 32-bit OS
+			if v2n > 1<<53 {
 				fnStrChk()
 				fnStrChk()
 			}
 			}
 		}
 		}
@@ -1412,12 +1414,12 @@ func TestBincUnderlyingType(t *testing.T) {
 func TestJsonLargeInteger(t *testing.T) {
 func TestJsonLargeInteger(t *testing.T) {
 	for _, i := range []uint8{'L', 'A', 0} {
 	for _, i := range []uint8{'L', 'A', 0} {
 		for _, j := range []interface{}{
 		for _, j := range []interface{}{
-			1 << 60,
-			-(1 << 60),
+			int64(1 << 60),
+			-int64(1 << 60),
 			0,
 			0,
 			1 << 20,
 			1 << 20,
 			-(1 << 20),
 			-(1 << 20),
-			uint(1 << 60),
+			uint64(1 << 60),
 			uint(0),
 			uint(0),
 			uint(1 << 20),
 			uint(1 << 20),
 		} {
 		} {