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

Add test coverage for pre-1970 dates #215

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

st3fan
Copy link

@st3fan st3fan commented Apr 18, 2021

This patch adds some extra tests for calendar.rs for the code paths that check for pre-1970 dates. I noticed that the tests only looked at the happy path so I added some that make sure an Err is returned when expected.

@codecov
Copy link

codecov bot commented Apr 18, 2021

Codecov Report

Merging #215 (0571f5c) into main (2208a22) will increase coverage by 2.40%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   50.60%   53.00%   +2.40%     
==========================================
  Files          17       17              
  Lines        1984     2079      +95     
==========================================
+ Hits         1004     1102      +98     
+ Misses        980      977       -3     
Impacted Files Coverage Δ
src/calendar.rs 94.19% <100.00%> (+5.18%) ⬆️
src/signed_data.rs 100.00% <0.00%> (ø)
tests/integration.rs 100.00% <0.00%> (ø)
tests/cert_v1_unsupported.rs 100.00% <0.00%> (ø)
tests/cert_without_extensions.rs 100.00% <0.00%> (ø)
src/name/dns_name.rs 62.45% <0.00%> (+1.05%) ⬆️
tests/dns_name_tests.rs 92.85% <0.00%> (+15.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2208a22...0571f5c. Read the comment docs.

assert_eq!(
Err(Error::BadDerTime),
time_from_ymdhms_utc(UNIX_EPOCH_YEAR - 1, 1, 1, 0, 0, 0)
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems OK to me, but I'd also like to see test cases for the very edge cases: the moment before the first of 1970 and exactly 1970.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the tests to cover:

  • 1969-12-31 00:00:00
  • 1969-12-31 23:59:59
  • 1970-01-01 00:00:00
  • 1970-01-01 00:00:01
  • 1971-01-01 00:00:00

This would catch off by one errors in date calculations.

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.

2 participants