tests/testthat/test-table-weights.R

test_that("get_weights_from_table", {
  data("idistrib1e4")
  tab1 <- idistrib1e4[[1]][1,]
  out <- get_weights_from_table(n = 1, x = 0, i_pos = 0)
  expect_equal(tab1[1] / sum(tab1), out)
  ##
  n <- 1
  x <- 1
  tab1 <- idistrib1e4[[n]][x + 1,]
  out <- get_weights_from_table(n = n, x = x, i_pos = 0)
  expect_equal(tab1[1] / sum(tab1), out)
  ##
  n <- 3
  x <- 1
  i_pos <- 2
  tab1 <- idistrib1e4[[n]][x + 1,]
  out <- get_weights_from_table(n = n, x = x, i_pos = i_pos)
  expect_equal(tab1[i_pos + 1] / sum(tab1), out)
})
skgallagher/TBornotTB documentation built on April 21, 2020, 1:19 p.m.