tests/testthat/test-Chebyshev.R

context("Chebyshev distance")

test_that("Chebyshev distance is correct", {
  comparator <- Chebyshev()
  expect_equal(comparator(c(1,2,3), c(2,3,4)), 1)
  expect_equal(comparator(-c(1,1,1), c(1,1,1)), 2)
  expect_equal(comparator(c(10,1,-2), c(0,-5,3)), 10)
  expect_equal(comparator(c(1,2), c(1,2)), 0)
  expect_equal(comparator(0, 0), 0)
  expect_equal(comparator(0, Inf), Inf)
})

Try the comparator package in your browser

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

comparator documentation built on March 18, 2022, 6:15 p.m.