Skip to content

Conversation

@swhitty
Copy link
Owner

@swhitty swhitty commented Jun 27, 2024

Adds additional IntDecodingStrategy to enabling clamping of BinaryInteger types to their representable range. An optional FloatingPointRoundingRule can also be provided to clamp and round.

let decoder = KeyValueDecoder()
decoder.intDecodingStrategy = .clamping(roundingRule: .toNearestOrAwayFromZero)

// [10, 21, 127, -128]
let values = try decoder.decode([Int8].self, from: [10, 20.5, 1000, -Double.infinity])

Renaming IntDecodingStrategy.rounded to IntDecodingStrategy.rounding

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.85%. Comparing base (44e0d68) to head (9c16e5c).

Files Patch % Lines
Sources/KeyValueDecoder.swift 96.42% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main       #9      +/-   ##
===========================================
- Coverage   100.00%   99.85%   -0.15%     
===========================================
  Files            3        3              
  Lines          654      670      +16     
===========================================
+ Hits           654      669      +15     
- Misses           0        1       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@swhitty swhitty merged commit b542a92 into main Jun 27, 2024
@swhitty swhitty deleted the int-decoding-clamping branch June 27, 2024 22:26
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.

3 participants