Skip to content

test: cover error paths in sentences/utils.rs - #179

Open
dpmcgarry wants to merge 1 commit into
AeroRust:mainfrom
dpmcgarry:test-utils-coverage
Open

dpmcgarry wants to merge 1 commit into
AeroRust:mainfrom
dpmcgarry:test-utils-coverage

Conversation

@dpmcgarry

Copy link
Copy Markdown

Hi -
I'm looking to contribute to this project to add some sentences needed in the marine space. I figured I would try to pick up some of the "Good first task" / "Help Wanted" as a first step.

This adds tests for:

  • parse_hms / parse_duration_hms: hour 24, minute 60, second 60, negative seconds, inf/NaN, non-digits, truncated input, missing comma, and the 00:00:00 / 23:59:59.999 boundaries
  • parse_date: month 0/13, day 0/32, 31 April, 30 February, 29 February in leap and non-leap years
  • do_parse_lat_lon: exactly 90°/180° (valid) vs. the smallest step past them, minutes ≥ 60, wrong/missing/lowercase hemisphere
  • parse_until_end, number, parse_num: previously untested; overflow, sign and empty input

I figured adding these in one PR was ok since it's ~135 lines. If you'd prefer more bite size just LMK.

Uncovered lines in utils.rs go from 13 to 3.

The remaining 3 lines are unreachable (I think): the two !is_finite() checks (the float parser already rejects inf/NaN) and the unreachable!() in do_parse_magnetic_variation.

Two things I found while writing these, left out of this PR:

  1. parse_hms("125959.9999999999,") returns 12:59:60. The fractional part rounds up to 1_000_000_000 ns, which chrono treats as a leap second. Happy to send a separate fix if you'd like it to return an error instead.
  2. parse_hms rejects -0 seconds (is_sign_negative), but parse_duration_hms accepts it (seconds < 0.0). Minor; I can align them if you want.

Thanks!

@dpmcgarry dpmcgarry changed the title Looking to address issue #25 and part of #11. test: cover error paths in sentences/utils.rs Nov 14, 2026
@dpmcgarry

Copy link
Copy Markdown
Author

hi - any chance someone could approve the workflows to run? I've got bandwidth to work on some stuff here so if I can get feedback on this PR I'm happy to pick up some other tasks in addition to adding some of the missing marine sentences I'd like included in this crate.

This branch has not been deployed

No deployments
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