Skip to content

Commit

Permalink
add unit tests for fix_utc_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLBaker committed Jan 11, 2024
1 parent 57fea08 commit b4de9b3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/testthat/test-dates_and_times.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
test_that("multiplication works", {
expect_equal(2 * 2, 4)
})

test_that("fix_utc_offset fixes offsets", {
datetimes <- c("2023-11-16T03:32:49+07:00","2023-11-16T03:32:49-07","2023-11-16T03:32:49","2023-11-16T03:32:49Z")
new_datetimes <- suppressWarnings(fix_utc_offset(datetimes))
expect_equal(new_datetimes, c("2023-11-16T03:32:49+0700",
"2023-11-16T03:32:49-0700",
"2023-11-16T03:32:49",
"2023-11-16T03:32:49+0000"))
})

test_that("convert_datetime_format returns datetimes in r format", {
new_datetimes <- convert_datetime_format(c("MM/DD/YYYY",
"YY-MM-DD"))
expect_equal(new_datetimes, c("%m/%d/%Y", "%y-%m-%d"))
})

0 comments on commit b4de9b3

Please sign in to comment.