mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 13:17:30 +02:00
restructuring
This commit is contained in:
parent
21c2dc0444
commit
4ad21c7f57
19 changed files with 432 additions and 80 deletions
|
|
@ -1,9 +1,20 @@
|
|||
mtcars$id <- seq_len(nrow(mtcars))
|
||||
|
||||
metadata_names <- function(...) {
|
||||
c(
|
||||
"field_name", "form_name", "section_header", "field_type",
|
||||
"field_label", "select_choices_or_calculations", "field_note",
|
||||
"text_validation_type_or_show_slider_number", "text_validation_min",
|
||||
"text_validation_max", "identifier", "branching_logic", "required_field",
|
||||
"custom_alignment", "question_number", "matrix_group_name", "matrix_ranking",
|
||||
"field_annotation"
|
||||
)
|
||||
}
|
||||
|
||||
test_that("ds2dd gives desired output", {
|
||||
expect_equal(ncol(ds2dd(mtcars, record.id = "id")), 18)
|
||||
expect_s3_class(ds2dd(mtcars, record.id = "id"), "data.frame")
|
||||
expect_s3_class(ds2dd(mtcars, record.id = 12), "data.frame")
|
||||
expect_equal(ncol(ds2dd(mtcars, record.id = "id",metadata = metadata_names())), 18)
|
||||
expect_s3_class(ds2dd(mtcars, record.id = "id",metadata = metadata_names()), "data.frame")
|
||||
expect_s3_class(ds2dd(mtcars, record.id = 12,metadata = metadata_names()), "data.frame")
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -11,19 +22,19 @@ test_that("ds2dd gives output with list of length two", {
|
|||
expect_equal(length(ds2dd(
|
||||
mtcars,
|
||||
record.id = "id",
|
||||
include.column.names = TRUE
|
||||
include.column.names = TRUE,metadata = metadata_names()
|
||||
)), 2)
|
||||
})
|
||||
|
||||
|
||||
test_that("ds2dd gives correct errors", {
|
||||
expect_error(ds2dd(mtcars))
|
||||
expect_error(ds2dd(mtcars, form.name = c("basis", "incl")))
|
||||
expect_error(ds2dd(mtcars, field.type = c("text", "dropdown")))
|
||||
expect_error(ds2dd(mtcars, field.label = c("Name", "Age")))
|
||||
expect_error(ds2dd(mtcars,metadata = metadata_names()))
|
||||
expect_error(ds2dd(mtcars, form.name = c("basis", "incl"),metadata = metadata_names()))
|
||||
expect_error(ds2dd(mtcars, field.type = c("text", "dropdown"),metadata = metadata_names()))
|
||||
expect_error(ds2dd(mtcars, field.label = c("Name", "Age"),metadata = metadata_names()))
|
||||
})
|
||||
|
||||
test_that("ds2dd correctly renames", {
|
||||
expect_equal(ncol(ds2dd(mtcars, record.id = "id")), 18)
|
||||
expect_s3_class(ds2dd(mtcars, record.id = "id"), "data.frame")
|
||||
expect_equal(ncol(ds2dd(mtcars, record.id = "id",metadata = metadata_names())), 18)
|
||||
expect_s3_class(ds2dd(mtcars, record.id = "id",metadata = metadata_names()), "data.frame")
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue