tests/testthat/test_conversion.R

context("Test type conversion")

test_that("Single integer strings are converted",{
  result <- rope:::as_int_single("12")
  expect_that(is.integer(result), equals(TRUE))
})


test_that("Multiple integer strings are converted",{
  result <- rope:::as_int_vector(c("12","19","103"))
  expect_that(is.integer(result), equals(TRUE))
})

test_that("Single numeric strings are converted",{
  result <- rope:::as_double_single("1.2")
  expect_that(is.numeric(result), equals(TRUE))
})


test_that("Multiple numeric strings are converted",{
  result <- rope:::as_double_vector(c("1.2","76.19","1354.03"))
  expect_that(is.numeric(result), equals(TRUE))
})


test_that("Single integer values are converted to strings",{
  result <- rope:::as_string_int_single(12)
  expect_that(is.character(result), equals(TRUE))
})


test_that("Multiple integer values are converted to strings",{
  result <- rope:::as_string_int_vector(c(12,19,103))
  expect_that(is.character(result), equals(TRUE))
})

test_that("Single numeric values are converted to strings",{
  result <- rope:::as_string_double_single(1.2)
  expect_that(is.character(result), equals(TRUE))
})


test_that("Multiple numeric values are converted to strings",{
  result <- rope:::as_string_double_vector(c(1.2,76.19,1354.03))
  expect_that(is.character(result), equals(TRUE))
})
PeteHaitch/rope documentation built on May 9, 2017, 6:35 p.m.