tests/testthat/test-utils.R

context("test-utils.R")

test_that("prune_zero_tail prune matrix and only if correctly provided", {
  mat_ok <- diag(c(1, 2, 3, 0, 0, 0, 0))
  mat_ko <- diag(c(1, 2, 3, 0, 0, 4, 0))

  expected <- diag(c(1, 2, 3))
  expect_equal(prune_zero_tail(mat_ok), expected)
  expect_equal(prune_zero_tail(expected), expected)
  expect_error(prune_zero_tail(mat_ko), 'cannot have non-zeros after')
})


test_that("is_zero", {
  expect_true(is_zero(0))
  expect_false(is_zero(1))
  expect_error(is_zero('a'), 'is_a_number')
})

Try the CrossClustering package in your browser

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

CrossClustering documentation built on May 1, 2019, 10:53 p.m.