From 5f59d4470796a477fbe713f10b5b4afe7e97bdd7 Mon Sep 17 00:00:00 2001 From: zargot Date: Tue, 8 Apr 2025 11:21:35 -0400 Subject: [PATCH] add test --- tests/testthat/test-59.R | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/testthat/test-59.R diff --git a/tests/testthat/test-59.R b/tests/testthat/test-59.R new file mode 100644 index 00000000..d0181b66 --- /dev/null +++ b/tests/testthat/test-59.R @@ -0,0 +1,38 @@ +library(devtools) + +load_all('.') + +data <- data.frame( + start_a = c(1) +) + +db <- "database_one" + +variables <- data.frame( + variable = c("a", "b", "c", "d"), + label = c("", "", "", ""), + labelLong = c("", "", "", ""), + units = c("N/A", "N/A", "N/A", "N/A"), + variableType = c("Continuous", "Continuous", "Continuous", "Continuous") +) + +variable_details <- data.frame( + variable = c("a", "b", "c", "d"), + typeEnd = c("cont", "cont", "cont", "cont"), + databaseStart = c(db, db, db, db), + variableStart = c("[start_a]", "DerivedVar::[a]", "DerivedVar::[b]", "[c]"), + recEnd = c("copy", "Func::b", "Func::c", "copy"), + recStart = c("else", "else", "else", "else") +) + +.GlobalEnv$b <- function(x) { + return(x+1) +} + +.GlobalEnv$c <- function(x) { + return(x+1) +} + +recoded_data <- rec_with_table( + data, variables, db, variable_details) +print(recoded_data)