tests/testthat/test-amount_3.R

library (surveyreader)
library(testthat)
context("Wrapper for 3-level amount evalution Eurobarometer questions.")

test_that("correct conversion takes place", {
  expect_equal(rescale_amount_3 (column = c("Too much",
                                            "About the right amount",
                                            "Too little",
                                            "NA", "DK")),
    c(1,0,-1,NA,NA)
  )
  expect_equal(rescale_amount_3(column =
                                  c("Too much",
                                    "About the right amount",
                                    "Too little",
                                    "NA", "DK"),
                                na_labels = "default",
                                return_class = "character"),
    c("too_much", "right_amount", "too_little",NA, NA)
  )
})
antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.