tests/testthat/test-fun_to_m.R

test_that("fun_to_m", {

  # setup -------------------------------------------------------------------

  nsp <- round(runif(1, 5, 10))
  np <- round(runif(1, 5, 10))

  x1 <- runif(nsp)
  m_sp <- fun_to_m(x = x1,
                   n_patch = np,
                   n_species = nsp,
                   param_attr = "species")

  x2 <- runif(np)
  m_p <- fun_to_m(x = x2,
                  n_patch = np,
                  n_species = nsp,
                  param_attr = "patch")

  # test --------------------------------------------------------------------

  expect_equal(apply(m_sp$m_x, 1, unique), x1)

  expect_equal(apply(m_p$m_x, 2, unique), x2)
})
aterui/mcbrnet documentation built on Nov. 14, 2024, 3:14 a.m.