tests/testthat/test-table_getNearestLocation.R

context("table_getNearestLocation")

test_that("table_getNearestLocation() works", {
  
  locationTbl <- get(data("wa_monitors_500"))
  
  emptyRecord <- table_initialize()    # zero rows
  emptyRecord[1,1] <- as.character(NA) # one row, all NA
  wenatcheeRecord <- locationTbl %>% dplyr::filter(city == "Wenatchee")
  
  # Wenatchee
  lon <- -120.325278
  lat <- 47.423333
  
  testClose <- table_getNearestLocation(locationTbl, lon, lat, distanceThreshold = 100)
  testFar <- table_getNearestLocation(locationTbl, lon, lat, distanceThreshold = 10000)
  expect_equal(testClose, emptyRecord)
  expect_equal(testFar, wenatcheeRecord)
  
})

Try the MazamaLocationUtils package in your browser

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

MazamaLocationUtils documentation built on Nov. 2, 2023, 6:16 p.m.