tests/testthat/test-get_incremental_names.R

# ---------------------------------------------------------------------------- #
test_that("get_incremental_names works for default sep", {
  vec_names <- c("item_1", "item_2", "item_3")
  expect_equal(get_incremental_names(3, "item"), vec_names)
})

# ---------------------------------------------------------------------------- #
test_that("get_incremental_names works for blank sep", {
  expect_equal(get_incremental_names(2, "item", sep = ""), c("item1", "item2"))
})

# ---------------------------------------------------------------------------- #
test_that("get_incremental_names works for more than 9 items", {
  ex <- c(
    "x_01", "x_02", "x_03", "x_04", "x_05", "x_06", "x_07", "x_08", "x_09",
    "x_10", "x_11"
  )
  expect_equal(get_incremental_names(11, "x"), ex)
})

# ---------------------------------------------------------------------------- #
test_that("get_incremental_names works for non-default start val", {
  expect_equal(get_incremental_names(3, "a", start = 0), c("a_0", "a_1", "a_2"))
})

# ---------------------------------------------------------------------------- #
toniprice/jute documentation built on Jan. 11, 2023, 8:23 a.m.