test: add NA-handling test for mixed date formats with explicit format #1608
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a focused, high-value test to ensure that
parse_date()behaves correctly when given mixed date formats while an explicitformatis supplied. The test verifies that:NA.This scenario was not previously covered in the test suite and improves coverage for real-world edge cases.
Rationale
When users provide an explicit
format,parse_date()should consistently:NAfor mismatched or invalid inputs.Adding this test ensures that these expectations remain stable and prevents future regressions around mixed-format date parsing — a common source of issues when working with heterogeneous datasets.
What this test covers
The added test checks a small vector containing:
It then asserts that:
NAThe test fits neatly within the existing structure of
test-parsing-datetime.R.Files changed
tests/testthat/test-parsing-datetime.R(new test block only)No source code or snapshot changes.
How to test
Run either:
or
Both will execute the new unit test.
This PR strengthens the reliability of date parsing in readr and adds coverage for a meaningful edge case that was previously untested.