Skip to content

Commit

Permalink
Test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Jun 27, 2024
1 parent c5fa179 commit ed1423a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/tree_distance_kendall-colijn.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ KCDiameter.numeric <- function(tree) {

#' @export
KCDiameter.list <- function(tree) {
lapply(tree, KCDiameter)
vapply(tree, KCDiameter, double(1))
}

#' @export
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-tree_distance_kc.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
library("TreeTools", quietly = TRUE)

test_that("KC fails gracefully", {
expect_error(KendallColijn(BalancedTree(8), BalancedTree(1:8)),
"Leaves must bear identical labels.")
})

test_that("KC vector calculations", {

bal7 <- ape::read.tree(text = "(((t1,t2),(t3,t4)),((t5,t6),t7));")
Expand Down Expand Up @@ -45,9 +50,11 @@ test_that("KCDiameter() calculated", {
Test(4)
Test(40)
tree1 <- ape::read.tree(text = "(a, (b, (c, (d, (e, (f, (g, h)))))));")
expect_equal(KendallColijn(tree1), 0)
tree2 <- ape::read.tree(text = "(a, ((b, c), (d, (e, (f, (g, h))))));")
tree3 <- ape::read.tree(text = "(a, (b, (c, (d, (e, (f, g))))));")
trees <- c(tree1, tree2, tree3)
expect_equal(KCDiameter(trees),
c(KCDiameter(tree1), KCDiameter(tree2), KCDiameter(tree3)))
expect_equal(KCDiameter(list(tree1, tree2, tree3)), KCDiameter(trees))
})

0 comments on commit ed1423a

Please sign in to comment.