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

Enhanced atoi tester with extended range checks #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kingcreek
Copy link

I have made some modifications to the existing atoi tester to include additional checks for the range of the atoi function, ensuring it behaves correctly when the input exceeds the capacity of a long. The standard behavior of atoi is to return LONG_MAX (2^31-1) or LONG_MIN (-2^31) and set the errno to ERANGE when a number cannot be represented within the bounds of a long. This pull request enhances the tester to validate this specific behavior.

Changes Made:

Added test cases to cover scenarios where the input to atoi exceeds the capacity of a long.
Checked that atoi correctly returns depending on the sign of the input when the range is exceeded.
The purpose of these changes is to ensure that the tester comprehensively assesses the range-handling capabilities of the atoi implementation, helping to identify potential issues related to integer overflow and range checks.

I believe these enhancements will contribute to the robustness of the tester and aid in improving the overall quality of the tested atoi implementation.

Enhances the testing of the atoi implementation in the repository. While the current test suite checks the basic functionality of atoi, it does not verify that it handles overflow conditions correctly, which is an important aspect of the original atoi function.

To address this limitation, introduces additional test cases that specifically check for overflow scenarios, such as when the input string represents a value greater/less than LONG_MAX or less/greater than LONG_MIN. The tests are designed to ensure that the atoi implementation correctly handles these overflow cases by returning values that may include 0, 1, 2, -1, -2, or similar values, mirroring the behavior of the original atoi function in these scenarios.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant