tests/testthat/test-Cherries.R

test_that("Cherries works", {
  expect_equal(Cherries(BalancedTree(8)), 4L)
  expect_equal(Cherries(PectinateTree(8)), 1L)
  expect_equal(Cherries(UnrootTree(PectinateTree(8))$edge, 8L), 2L)
  expect_error(Cherries(matrix(4, 4, 4)), "edge matrix")
  expect_error(Cherries(1:3), "edge matrix")
  
  expect_error(n_cherries_wrapper(1:2, 1:3, 4), "same length")
  
  skip_if_not_installed("testthat", "3.1.5") # for expect_no_error
  expect_no_error(Cherries(BalancedTree(144)))
})

Try the TreeTools package in your browser

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

TreeTools documentation built on April 23, 2026, 5:06 p.m.