Skip to content

Commit 53ce8bb

Browse files
committed
Fix int64 minimum value handling in tests for cross-architecture compatibility
Update test cases that use the int64 minimum value (-9223372036854775808) to avoid overflow errors on 32-bit (i386) architectures. Signed-off-by: Arthur Diniz <[email protected]>
1 parent 0fe7da3 commit 53ce8bb

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

goyaml.v2/decode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ var unmarshalTests = []struct {
131131
map[string]interface{}{"bin": -42},
132132
}, {
133133
"bin: -0b1000000000000000000000000000000000000000000000000000000000000000",
134-
map[string]interface{}{"bin": -9223372036854775808},
134+
map[string]int64{"bin": -9223372036854775808},
135135
}, {
136136
"decimal: +685_230",
137137
map[string]int{"decimal": 685230},

goyaml.v3/decode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ var unmarshalTests = []struct {
177177
map[string]interface{}{"bin": -42},
178178
}, {
179179
"bin: -0b1000000000000000000000000000000000000000000000000000000000000000",
180-
map[string]interface{}{"bin": -9223372036854775808},
180+
map[string]int64{"bin": -9223372036854775808},
181181
}, {
182182
"decimal: +685_230",
183183
map[string]int{"decimal": 685230},

yaml_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ type MarshalTest struct {
183183
func TestMarshal(t *testing.T) {
184184
f32String := strconv.FormatFloat(math.MaxFloat32, 'g', -1, 32)
185185
s := MarshalTest{"a", math.MaxInt64, math.MaxFloat32}
186-
e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", math.MaxInt64, f32String))
186+
e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", int64(math.MaxInt64), f32String))
187187

188188
y, err := Marshal(s)
189189
if err != nil {
@@ -411,8 +411,8 @@ func TestUnmarshal(t *testing.T) {
411411
// decoding integers
412412
"decode 2^53 + 1 into int": {
413413
encoded: []byte("9007199254740993"),
414-
decodeInto: new(int),
415-
decoded: 9007199254740993,
414+
decodeInto: new(int64),
415+
decoded: int64(9007199254740993),
416416
},
417417
"decode 2^53 + 1 into interface": {
418418
encoded: []byte("9007199254740993"),

0 commit comments

Comments
 (0)