Skip to content

Commit

Permalink
updated function and added new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arrismo committed Oct 11, 2024
1 parent a31110d commit 0d40afe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions R/date_time_parsing.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ log_date_time_parse <- function(.data, .fun){
new_na_count <- na_count_parsed - na_count_original
success_index <- which(!is.na(parsed_dates))[1]
failed_index <- which(!is.na(dates_char) & is.na(parsed_dates))[1]

if(new_na_count ){


}
cli_alert_danger("NA values created by parsing: {new_na_count}")

# Add successful parse example if exists
Expand Down
21 changes: 14 additions & 7 deletions tests/testthat/test-dmy.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
library(lubrilog)
library(cli)


cli::test_that_cli("danger",{
test_that("dmy works", {
expect_error(lubrilog::dmy(games$release_date))
})
})
data <- lubrilog::games


f <- function(){
cli_alert_danger("NA values created by parsing:")
cli_alert_danger("Example failed parse:")
cli_alert(" Original: {dates_char[failed_index]}")
cli_alert(" Parsed: NA")
}

test_that("dmy works", {
expect_error(lubrilog::dmy(games$release_date),NA)
expect_message(
out <- lubrilog::dmy(data$release_date)
)
expect_equal(length(out), nrow(data))

})

0 comments on commit 0d40afe

Please sign in to comment.