Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enforce int64 for large integer values in tests #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goyaml.v2/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var unmarshalTests = []struct {
map[string]interface{}{"bin": -42},
}, {
"bin: -0b1000000000000000000000000000000000000000000000000000000000000000",
map[string]interface{}{"bin": -9223372036854775808},
map[string]interface{}{"bin": int64(-9223372036854775808)},
}, {
"decimal: +685_230",
map[string]int{"decimal": 685230},
Expand Down
2 changes: 1 addition & 1 deletion goyaml.v3/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var unmarshalTests = []struct {
map[string]interface{}{"bin": -42},
}, {
"bin: -0b1000000000000000000000000000000000000000000000000000000000000000",
map[string]interface{}{"bin": -9223372036854775808},
map[string]interface{}{"bin": int64(-9223372036854775808)},
}, {
"decimal: +685_230",
map[string]int{"decimal": 685230},
Expand Down
6 changes: 3 additions & 3 deletions yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ type MarshalTest struct {
func TestMarshal(t *testing.T) {
f32String := strconv.FormatFloat(math.MaxFloat32, 'g', -1, 32)
s := MarshalTest{"a", math.MaxInt64, math.MaxFloat32}
e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", math.MaxInt64, f32String))
e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", int64(math.MaxInt64), f32String))

y, err := Marshal(s)
if err != nil {
Expand Down Expand Up @@ -411,8 +411,8 @@ func TestUnmarshal(t *testing.T) {
// decoding integers
"decode 2^53 + 1 into int": {
encoded: []byte("9007199254740993"),
decodeInto: new(int),
decoded: 9007199254740993,
decodeInto: new(int64),
decoded: int64(9007199254740993),
},
"decode 2^53 + 1 into interface": {
encoded: []byte("9007199254740993"),
Expand Down