stRoke/tests/testthat/test-ds2dd.R

41 lines
975 B
R
Raw Permalink Normal View History

2023-04-12 13:59:26 +02:00
talos$id <- seq_len(nrow(talos))
test_that("ds2dd gives desired output", {
2023-04-12 19:55:40 +02:00
expect_equal(ncol(ds2dd(talos, record.id = "id")), 18)
expect_s3_class(ds2dd(talos, record.id = "id"), "data.frame")
expect_s3_class(ds2dd(talos, record.id = 7), "data.frame")
2023-04-12 13:59:26 +02:00
})
2023-04-12 19:55:40 +02:00
2023-04-12 13:59:26 +02:00
test_that("ds2dd gives output with list of length two", {
2023-04-12 19:55:40 +02:00
expect_equal(length(ds2dd(
talos,
record.id = "id",
include.column.names = TRUE
)), 2)
2023-04-12 13:59:26 +02:00
})
test_that("ds2dd gives correct errors", {
expect_error(ds2dd(talos))
2023-04-12 19:55:40 +02:00
expect_error(ds2dd(talos, form.name = c("basis", "incl")))
expect_error(ds2dd(talos, field.type = c("text", "dropdown")))
expect_error(ds2dd(talos, field.label = c("Name", "Age")))
2023-04-12 13:59:26 +02:00
})
2023-04-12 19:55:40 +02:00
colnames(talos) <-
c("rtreat",
"mRS 1",
"mRS 6",
"hypertension",
"diabetes",
"civil",
"id")
2023-04-12 13:59:26 +02:00
test_that("ds2dd correctly renames", {
2023-04-12 19:55:40 +02:00
expect_equal(ncol(ds2dd(talos, record.id = "id")), 18)
expect_s3_class(ds2dd(talos, record.id = "id"), "data.frame")
2023-04-12 13:59:26 +02:00
})