Skip to content

Commit

Permalink
Updated is_valid_dtc, fixed test, removed empty test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bms63 committed Aug 23, 2022
1 parent 632018e commit 95b5599
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
18 changes: 8 additions & 10 deletions R/is.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,14 @@ on_failure(is_order_vars) <- function(call, env) {
#' @family is
#'
is_valid_dtc <- function(arg) {
pattern <- paste(
"^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}).(\\d{3})$",
"^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})$",
"^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})$",
"^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})$",
"^(\\d{4})-(\\d{2})-(\\d{2})$",
"^(\\d{4})-(\\d{2})$",
"^(\\d{4})$",
"^(\\d{4})---(\\d{2})$",
sep = "|"
twod <- "(\\d{2}|-)"
pattern <- paste0(
"^(\\d{4}|-)?",
"(-", twod, ")?",
"(-", twod, ")?",
"(T", twod, ")?",
"(:", twod, ")?",
"(:", twod, "(.(\\d{1,5}))?)?$"
)

grepl(pattern, arg) | arg == "" | is.na(arg)
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-quo.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ test_that("Test 11 : `quo_not_missing` throws and Error if missing argument", {
}
expect_error(test_fun()) # missing argument -> throws error
})

test_that("Test 11 : `quo_not_missing` throws and Error if missing argument", {
# quo_c test here
})
2 changes: 1 addition & 1 deletion tests/testthat/test-warnings.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test_that("A warning is issued when a variable to be derived already exists in t

test_that("A warning is issued when a vector contain unknown datetime format", {
expect_warning(
warn_if_invalid_dtc(dtc = "2021-04-06T-:30:30")
warn_if_invalid_dtc(dtc = "20210406T12:30:30")
)
})

Expand Down

0 comments on commit 95b5599

Please sign in to comment.