Debian Codegraph @

tests/testthat/test-depth.R

raw
1 # library(testthat)
2 # library(dendextend)
3
4
5 context("depth")
6
7
8 test_that("min_depth works", {
9
10 dend <- as.dendrogram(hclust(dist(mtcars)))
11
12 expect_identical(
13 min_depth(dend),
14 3
15 )
16
17 # if non-list object passed in
18 x <- 1:4
19 expect_identical(
20 min_depth(x),
21 1L
22 )
23 # if leaf is passed in as a list
24 expect_error(
25 min_depth(as.list(dend[[1]][[1]]))
26 )
27
28 })
29
30
31 test_that("max_depth works", {
32
33 dend <- as.dendrogram(hclust(dist(mtcars)))
34
35 expect_identical(
36 max_depth(dend),
37 11
38 )
39
40 # if non-list object passed in
41 x <- 1:4
42 expect_identical(
43 max_depth(x),
44 1L
45 )
46 # if leaf is passed in as a list
47 expect_error(
48 max_depth(as.list(dend[[1]][[1]]))
49 )
50
51 })