tests/testthat/test-coordinates.R

test_that("format_coordinates builds readable labels", {
  expect_equal(format_coordinates(c(48.52, 9.06)), "48.5°N, 9.1°E")
  expect_equal(format_coordinates(c(-48.52, -9.06)), "48.5°S, 9.1°W")
  expect_equal(format_coordinates(c(0, 0)), "0°N, 0°E")
  expect_equal(format_coordinates(c(48.52, 9.06), digits = 2), "48.52°N, 9.06°E")
})

test_that("format_coordinates validates inputs", {
  expect_error(format_coordinates(c(48, 9, 10)))
  expect_error(format_coordinates(c(NA_real_, 9)))
  expect_error(format_coordinates("not numeric"))
  expect_error(format_coordinates(c(48, 9), digits = -1))
  expect_error(format_coordinates(c(48, 9), digits = c(1, 2)))
})

Try the LightLogR package in your browser

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

LightLogR documentation built on Nov. 28, 2025, 5:09 p.m.