Skip to content

Add test coverage for pre-1970 dates - #215

Open
st3fan wants to merge 4 commits into
briansmith:mainfrom
st3fan:st3fan/calendar-tests
Open

Add test coverage for pre-1970 dates#215
st3fan wants to merge 4 commits into
briansmith:mainfrom
st3fan:st3fan/calendar-tests

Conversation

@st3fan

@st3fan st3fan commented Apr 18, 2021

Copy link
Copy Markdown

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

codecov Bot commented Apr 18, 2021

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.00%. Comparing base (2208a22) to head (0571f5c).
⚠️ Report is 67 commits behind head on main.

Additional details and impacted files
@@            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     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/calendar.rs
assert_eq!(
Err(Error::BadDerTime),
time_from_ymdhms_utc(UNIX_EPOCH_YEAR - 1, 1, 1, 0, 0, 0)
);

Copy link
Copy Markdown
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
Copy Markdown
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