tests/testthat/test_haversine.R

library(spatialrisk)
context("haversine")


test_that("return correct output", {
  uit <- haversine(52, 6, 53, 7)
  expect_equal(round(uit, 0), round(130321.2, 0))
  })

test_that("return NA for missing coordinates", {
  uit <- haversine(c(52, 51), c(6, 6.1), c(53,51), c(NA, 6))
  expect_equal(sum(is.na(uit)), 1)
})

Try the spatialrisk package in your browser

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

spatialrisk documentation built on Nov. 10, 2021, 5:09 p.m.