tests/testthat/test-good_bad_3.R

library (surveyreader)
library(testthat)
context("Wrapper for 3-level good-bad Eurobarometer questions.")

test_that("correct conversion takes place", {
  expect_equal(rescale_good_bad_3 (column = c(
      "A good thing",
      "Neither good nor bad",
      "A bad thing", "NA", "DK")),
    c(1,0,-1,NA,NA)
  )
  expect_equal(rescale_good_bad_3 (column =
                                     c("A good thing",
                                     "Neither good nor bad",
                                     "A bad thing", "NA", "DK"),
    na_labels = "default",
    return_class = "character"),
    c("good", "none", "bad",NA, NA)
  )
})
antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.