tests/testthat/test-cdb_id.R

test_that("cdb_id works correctly", {
  id1 <- cdb_id(Compadre, c("SpeciesAuthor", "MatrixPopulation"))
  expect_type(id1, "integer")
  expect_length(id1, nrow(Compadre@data))

  id2 <- cdb_id(Compadre, "Family")
  expect_type(id2, "integer")
  expect_length(id2, nrow(Compadre@data))
  expect_length(unique(id2), length(unique(Compadre@data$Family)))
})


test_that("cdb_id warns and fails gracefully", {
  expect_error(cdb_id(Compadre@data))
  expect_error(cdb_id(Compadre, c("SpeciesAuthor", "blah")))
})

Try the Rcompadre package in your browser

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

Rcompadre documentation built on Oct. 17, 2024, 1:07 a.m.