tests/testthat/test-ESmisc.R

context("requests")

test_that("geocode_cadastral returns coordinates from cadastral reference.", {
  result <- geocode_cadastral("0636105UF3403N", parse_files = FALSE)
  
  expect_match(result, "[0-9]{1,2}.[0-9]*,[0-9]{1,2}.[0-9]*")
})


test_that("to_number returns integer from string.", {
  result <- to_number("mil doscientos treinta y cuatro")

  expect_type(result, "integer")
})


test_that("to_number returns a correct translation from string.", {
  result <- to_number("mil doscientos treinta y cuatro")
  target <- 1234
  expect_equivalent(result, target)
})


test_that("to_number works ok with millions from string.", {
  result <- to_number("dos millones cuatrocientos ochenta y dosmil ciento tres")
  target <- 2482103
  expect_equivalent(result, target)
})


test_that("to_number error message when unexpected string.", {

  expect_error(to_number("Esto no es un numero, ya ves."), "*unexpected input*")
})
verajosemanuel/ESmisc documentation built on Jan. 4, 2023, 12:37 p.m.