tests/testthat/test-distance.R

context("distance")
# testing for distance function

test_that("Distance Function Simple Example - Orthogonal 2 samples", {
  X <- rbind(c(0, 1), c(1, 0))
  D <- mgc.distance(X)
  expect_equal(as.numeric(D), as.numeric(cbind(c(0, sqrt(2)), c(sqrt(2), 0))))
})

test_that("Distance Function Simple Example - Same 2 samples", {
  X <- rbind(c(1, 0), c(1, 0))
  D <- mgc.distance(X)
  expect_equal(as.numeric(D), as.numeric(cbind(c(0, 0), c(0, 0))))
})

Try the mgc package in your browser

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

mgc documentation built on July 1, 2020, 7:09 p.m.