tests/testthat/test-roxytest-tests-dates.R

# Generated by roxytest: Do not edit by hand!

# File R/dates.R: @tests

test_that("Function date_exact() @ L29", {
  expect_equal(date_exact(2005), character())
  expect_equal(date_exact(2005, 8), character())
  expect_equal(date_exact(2005, 8, 12), "12 AUG 2005")
})


test_that("Function date_calendar() @ L61", {
  expect_equal(date_calendar(2005), "2005")
  expect_equal(date_calendar(103, year_is_bce = TRUE), "103 BCE")
  expect_equal(date_calendar(2005, 1), "JAN 2005")
  expect_equal(date_calendar(2005, 1, 14), "14 JAN 2005")
})


test_that("Function date_range() @ L108", {
  expect_error(date_range("ABT 2008"))
  expect_equal(date_range(start_date = date_calendar(2005)), 
               "AFT 2005")
  expect_equal(date_range(end_date = date_calendar(2010)), 
               "BEF 2010")
  expect_equal(date_range(end_date = date_calendar(2005, 10, 14)), 
               "BEF 14 OCT 2005")
  expect_equal(date_range(date_calendar(2005, 1, 14), date_calendar(2006, 7, 9)), 
               "BET 14 JAN 2005 AND 9 JUL 2006")
  expect_equal(date_range(), character())
})


test_that("Function date_period() @ L163", {
  expect_error(date_period("ABT 2008"))
  expect_equal(date_period(start_date = date_calendar(2005)), 
               "FROM 2005")
  expect_equal(date_period(start_date = date_calendar(2005, 1)), 
               "FROM JAN 2005")
  expect_equal(date_period(start_date = date_calendar(2005, 1, 14)), 
               "FROM 14 JAN 2005")
  expect_equal(date_period(end_date = date_calendar(2005)), 
               "TO 2005")
  expect_equal(date_period(end_date = date_calendar(2010, 6)), 
               "TO JUN 2010")
  expect_equal(date_period(start_date = date_calendar(2005, 10, 14), end_date = date_calendar(2008, 9)), 
               "FROM 14 OCT 2005 TO SEP 2008")
  expect_equal(date_period(start_date = date_calendar(1750, 10, year_is_dual = TRUE), 
                           end_date = date_calendar(2008, 9)), 
               "FROM OCT 1750/51 TO SEP 2008")
  expect_equal(date_period(date_calendar(1900, 6, 30), date_calendar(1901)), 
               "FROM 30 JUN 1900 TO 1901")
})


test_that("Function date_approximated() @ L206", {
  expect_equal(date_approximated(date_calendar(2005, 1, 14), calc = TRUE), "CAL 14 JAN 2005")
  expect_equal(date_approximated(date_calendar(2005), est = TRUE), "EST 2005")
  expect_equal(date_approximated(date_calendar(2005, 1)), "ABT JAN 2005")
  expect_equal(date_approximated(), character())
  expect_equal(date_approximated(date_calendar(2005, 1), FALSE,FALSE,FALSE), "JAN 2005")
})


test_that("Function parse_gedcom_date() @ L238", {
  expect_equal(is.na(parse_gedcom_date(NA)), TRUE)
  expect_equal(parse_gedcom_date("4 APR"), as.Date("1000-04-04"))
  expect_equal(parse_gedcom_date("4 APR", minimise = FALSE), as.Date("4000-04-04"))
})


test_that("Function parse_gedcom_age() @ L282", {
  expect_equal(is.na(parse_gedcom_age(NA)), TRUE)
  expect_equal(parse_gedcom_age("16y"), 16)
  expect_equal(parse_gedcom_age("16y 6m"), 16.5)
  expect_equal(parse_gedcom_age("73d"), 0.2)
})
jl5000/tidyged.internals documentation built on Aug. 21, 2022, 8:32 p.m.