tests/testthat/test-sample-trees-many-index-cases.R

test_that("sample_unique_perms_o", {
  g <- 1
  n <- 1
  B <- 2
  out <- sample_unique_perms_o(g, n, B)
  expect_equal(as.numeric(out), rep(1, B))
  ################
  g <- 2
  n <- 2
  B <- 2
  out <- sample_unique_perms_o(g, n, B)
  expect_equal(dim(out), c(g, B))

  expect_true(all(colSums(out) == n))
  ################
  g <- 5
  n <- 10
  B <- 5
  out <- sample_unique_perms_o(g, n, B)
  expect_equal(dim(out), c(g, B))
  expect_true(all(colSums(out) == n))
  ##############
  ##############
  g <- 10
  n <- 10
  B <- 5
  out <- sample_unique_perms_o(g, n, B)
  expect_equal(dim(out), c(g, B))
  expect_true(all(colSums(out) == n))
  ################
  ################
  g <- 4
  n <- 10
  B <- 100
  out <- sample_unique_perms_o(g, n, B)
  expect_equal(dim(out), c(g, B))
  expect_true(all(colSums(out) == n))
})


test_that("sample_uniform_trees_nxo", {
  n <- 1
  x <- 1
  B <- 10
  out <- sample_uniform_trees_nxo(n = n, x = x, B)
  expect_equal(dim(out), c(1, 5))
  #############
  n <- 10
  x <- 10
  B <- 10
  out <- sample_uniform_trees_nxo(n = n, x = x, B)
  expect_true(all(out$i_pos <= n-1))
  expect_true(all(out$i_neg == 0))
  #############
  n <- 10
  x <- 0
  B <- 10
  out <- sample_uniform_trees_nxo(n = n, x = x, B)
  expect_true(all(out$i_pos == 0))
  #######
  n <- 10
  x <- 3
  B <- 10
  out <- sample_uniform_trees_nxo(n = n, x = x, B)
  expect_equal(sum(out$freq), B)
  #############



})
skgallagher/TBornotTB documentation built on April 21, 2020, 1:19 p.m.