tests/testthat/test_next_fy.R

context("Next fy")

expect_equal <- function(left, right) {
  testthat::expect_equal(unclass(left),
                         unclass(right), 
                         check.attributes = FALSE)
}

test_that("next_fy plus and minus", {
  expect_equal(next_fy("2015-16"), "2016-17")
  expect_equal(next_fy(c("2015-16", "2018-19")),
               c("2016-17", "2019-20"))
  expect_equal(next_fy("1999-00", h = 3), "2002-03")
  expect_equal(next_fy("2002-03", h = -3), "1999-00")
})

test_that("prev_fy", {
  expect_equal(prev_fy("2015-16"), "2014-15")
  expect_equal(prev_fy(c("2016-17", "2019-20")),
               c("2015-16", "2018-19"))
})

Try the grattan package in your browser

Any scripts or data that you put into this service are public.

grattan documentation built on Sept. 4, 2023, 5:08 p.m.