From a1d9efaa3b3f170e4be505c0d5bea9e6cb6e1224 Mon Sep 17 00:00:00 2001 From: tanmaydimriGSOC Date: Fri, 28 Nov 2025 00:27:08 +0530 Subject: [PATCH 1/2] test: add NA-handling test for mixed date formats with explicit format --- tests/testthat/test-parsing-datetime.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/testthat/test-parsing-datetime.R b/tests/testthat/test-parsing-datetime.R index ed1b8737..fce24cf0 100644 --- a/tests/testthat/test-parsing-datetime.R +++ b/tests/testthat/test-parsing-datetime.R @@ -348,3 +348,18 @@ test_that("Invalid formats error", { error = TRUE ) }) + +test_that("parse_date() handles mixed or malformed date inputs safely", { + x <- c("2024-01-05", "05/01/2024", "not-a-date") + + parsed <- parse_date( + x, + format = "%Y-%m-%d", + locale = locale(date_names = "en") + ) + + expect_equal(parsed[1], as.Date("2024-01-05")) + expect_true(is.na(parsed[2])) + expect_true(is.na(parsed[3])) +}) + From 2f99fc7d7e77506ff92fdcc7baef2010c857c112 Mon Sep 17 00:00:00 2001 From: tanmaydimriGSOC Date: Fri, 28 Nov 2025 01:04:37 +0530 Subject: [PATCH 2/2] style: format test file using styler --- tests/testthat/test-parsing-datetime.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-parsing-datetime.R b/tests/testthat/test-parsing-datetime.R index fce24cf0..2612ce42 100644 --- a/tests/testthat/test-parsing-datetime.R +++ b/tests/testthat/test-parsing-datetime.R @@ -362,4 +362,3 @@ test_that("parse_date() handles mixed or malformed date inputs safely", { expect_true(is.na(parsed[2])) expect_true(is.na(parsed[3])) }) -