tests/testthat/test-characters.R

context("Character functions")
filename <- MostRecentNexus() # if in testthat/tests

test_that("Character data is read from file", {
  expect_equal(1, length(filename))
  my_data <- TreeSearch::ReadAsPhyDat(filename)
  expect_equal(54, length(names(my_data)))
  expect_equal(225, sum(attr(my_data, 'weight')))
})

test_that("Character descriptions are extracted", {
  my_chars <- TreeSearch::ReadCharacters(filename)
  states <- attr(my_chars, 'state.labels')
  expect_equal(129, sum(vapply(states, IsNeomorphic, logical(1))))
  expect_equal(225, ncol(my_chars))
  expect_equal(4975, sum(!my_chars %in% c('-', '?')))
})

test_that("Character notes are extracted", {
  char_notes <- ReadNotes(filename)
  expect_equal(225, length(char_notes))
})
ms609/MorphoBank documentation built on April 21, 2023, 11:37 p.m.