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

feat: introduce safe integer conversion with error handling #812

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

appleboy
Copy link
Owner

  • Add errors and math packages to imports
  • Introduce safeIntToInt32 function to safely convert int to int32 with error handling for out-of-range values
  • Replace direct int32 conversion with safeIntToInt32 in Send function
  • Add unit tests for safeIntToInt32 function with various test cases including valid, overflow, and underflow scenarios

- Add `errors` and `math` packages to imports
- Introduce `safeIntToInt32` function to safely convert `int` to `int32` with error handling for out-of-range values
- Replace direct `int32` conversion with `safeIntToInt32` in `Send` function
- Add unit tests for `safeIntToInt32` function with various test cases including valid, overflow, and underflow scenarios

Signed-off-by: appleboy <appleboy.tw@gmail.com>
@appleboy appleboy merged commit 92164df into master Sep 17, 2024
8 of 9 checks passed
@appleboy appleboy deleted the convert branch September 17, 2024 04:00
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