tests/testthat/test-shannon_index.R

test_that("input error", {
  expect_error(shannon_index())
  expect_error(shannon_index("invalid"))
})

tibble_example <- dplyr::tibble(Plant = c("A","B","C","D","E"), count = c(10,5,8,20,10))

test_that("test cases", {
  expect_equal(shannon_index(tibble_example),1.50521514)
})

rm(tibble_example)

Try the SoilManageR package in your browser

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

SoilManageR documentation built on June 8, 2025, 9:36 p.m.