tests/testthat/test-rescale_attachment_4.R

library (surveyreader)
library(testthat)
context("Convert attachment 4-level description categories.")

test_that("correct conversion takes place", {
  expect_equal( rescale_attachment_4  (column =
                                       c("Very attached",
                                         "Fairly attached",
                                         "Not very attached",
                                         "Not at all attached",
                                         "DK", "NT/NV"),
                                     na_labels = "default",
                                     return_class = "character"),
                c("very_attached", "attached",
                 "not_very_attached", "not_attached",
                  NA, NA)
  )
  expect_equal( rescale_attachment_4  (column =
                                         c("Very attached",
                                           "Fairly attached",
                                           "Not very attached",
                                           "Not at all attached",
                                           "DK", "NT/NV"),
                                     na_labels = "default",
                                     return_class = "numeric"),
    c(2, 1, -1, -2, NA, NA)
  )
})
antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.