tests/testthat/test-spanish.R

context("requests")

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*")
})

Try the spanish package in your browser

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

spanish documentation built on Jan. 8, 2018, 5:04 p.m.