-
Notifications
You must be signed in to change notification settings - Fork 76
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
base: master
Are you sure you want to change the base?
fix: enforce int64 for large integer values in tests #120
Conversation
- Updated test cases in `goyaml.v2` and `goyaml.v3` `decode_test.go` to explicitly use `int64` for representing large integer values. - Adjusted `yaml_test.go` to: - Use `int64` for `math.MaxInt64` in marshaling tests. - Decode integers greater than `2^53` into `int64` instead of `int` to ensure proper handling of large values. These changes address potential issues with integer overflow and ensure compatibility across platforms with differing integer size representations. Signed-off-by: Arthur Diniz <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: arthurbdiniz The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The committers listed above are authorized under a signed CLA. |
Welcome @arthurbdiniz! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an amended commit to my fork and for some reason it was not synced here.
The bug arises from the use of generic integer types
(int)
in test cases involving large numerical values that exceed the range of a32-bit
integer.In Go, the size of the int type depends on the platform, this behavior causes inconsistencies when handling large integers, such as
-9223372036854775808
and9007199254740993
.On 32-bit systems, these values cannot be represented correctly as int, leading to potential overflow or truncation errors. By explicitly using the
int64
type in the affected test cases, the code ensures proper handling and representation of large integers across all platforms, avoiding platform-specific bugs and improving the reliability of the tests.Reproduce
Run tests setting
GOARCH
to386
.Changes
goyaml.v2
andgoyaml.v3
decode_test.go
to explicitly useint64
for representing large integer values.yaml_test.go
to:int64
formath.MaxInt64
in marshaling tests.2^53
intoint64
instead ofint
to ensure proper handling of large values.These changes address potential issues with integer overflow and ensure compatibility across platforms with differing integer size representations.