From e33dc4d8270ecf9613e2252057f841618508659c Mon Sep 17 00:00:00 2001 From: Rowley Date: Tue, 19 Dec 2023 17:33:06 +0000 Subject: [PATCH] Updated tests --- tests/testthat/test-summarise_ci.R | 6 +-- tests/testthat/test-summarise_coding_tools.R | 40 +++++++++---------- tests/testthat/test-summarise_dep_man.R | 6 +-- .../test-summarise_languages_by_prof.R | 2 +- tests/testthat/test-summarise_rep_workflow.R | 6 +-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/testthat/test-summarise_ci.R b/tests/testthat/test-summarise_ci.R index 2af1805..503f29c 100644 --- a/tests/testthat/test-summarise_ci.R +++ b/tests/testthat/test-summarise_ci.R @@ -2,7 +2,7 @@ dummy_data <- data.frame(CI = c(NA, rep("Yes", 2), rep("No", 3), - rep("I don't know", 4))) + rep("I don't know what continuous integration is", 4))) test_that("summarise_ci validation works", { @@ -26,10 +26,10 @@ test_that("summarise_ci output is as expected", { expected <- data.frame(value = factor(c("Yes", "No", - "I don't know"), + "I don't know what continuous integration is"), levels = c("Yes", "No", - "I don't know")), + "I don't know what continuous integration is")), n = c(2/9, 1/3, 4/9)) expect_equal(got, expected) diff --git a/tests/testthat/test-summarise_coding_tools.R b/tests/testthat/test-summarise_coding_tools.R index 1d2dbf0..ac12fab 100644 --- a/tests/testthat/test-summarise_coding_tools.R +++ b/tests/testthat/test-summarise_coding_tools.R @@ -1,22 +1,22 @@ # Coding tools frequency tables (access or knowledge) dummy_data <- data.frame( - knowledge_R = c("Yes", rep("No", 2), rep("Don't Know", 3)), - access_R = c(rep("Yes", 2), "No", rep("Don't Know", 3)), - knowledge_SQL = c(rep("Yes", 3), rep("No", 2), "Don't Know"), - access_SQL = c("Yes", rep("No", 3), rep("Don't Know", 2)), - knowledge_SAS = c(rep("Yes", 2), rep("No", 3), "Don't Know"), - access_SAS = c(rep("Yes", 3), "No", rep("Don't Know", 2)), - knowledge_VBA = c("Yes", rep("No", 2), rep("Don't Know", 3)), - access_VBA = c(rep("Yes", 2), "No", rep("Don't Know", 3)), - knowledge_python = c(rep("Yes", 3), rep("No", 2), "Don't Know"), - access_python = c("Yes", rep("No", 3), rep("Don't Know", 2)), - knowledge_SPSS = c(rep("Yes", 2), rep("No", 3), "Don't Know"), - access_SPSS = c(rep("Yes", 3), "No", rep("Don't Know", 2)), - knowledge_stata = c("Yes", rep("No", 2), rep("Don't Know", 3)), - access_stata = c(rep("Yes", 2), "No", rep("Don't Know", 3)), - knowledge_matlab = c(rep("Yes", 3), rep("No", 2), "Don't Know"), - access_matlab = c("Yes", rep("No", 5), rep("Don't Know", 0)) # Used to check zero counts aren't missing + knowledge_R = c("Yes", rep("No", 2), rep("Don't know", 3)), + access_R = c(rep("Yes", 2), "No", rep("Don't know", 3)), + knowledge_SQL = c(rep("Yes", 3), rep("No", 2), "Don't know"), + access_SQL = c("Yes", rep("No", 3), rep("Don't know", 2)), + knowledge_SAS = c(rep("Yes", 2), rep("No", 3), "Don't know"), + access_SAS = c(rep("Yes", 3), "No", rep("Don't know", 2)), + knowledge_VBA = c("Yes", rep("No", 2), rep("Don't know", 3)), + access_VBA = c(rep("Yes", 2), "No", rep("Don't know", 3)), + knowledge_python = c(rep("Yes", 3), rep("No", 2), "Don't know"), + access_python = c("Yes", rep("No", 3), rep("Don't know", 2)), + knowledge_SPSS = c(rep("Yes", 2), rep("No", 3), "Don't know"), + access_SPSS = c(rep("Yes", 3), "No", rep("Don't know", 2)), + knowledge_stata = c("Yes", rep("No", 2), rep("Don't know", 3)), + access_stata = c(rep("Yes", 2), "No", rep("Don't know", 3)), + knowledge_matlab = c(rep("Yes", 3), rep("No", 2), "Don't know"), + access_matlab = c("Yes", rep("No", 5), rep("Don't know", 0)) # Used to check zero counts aren't missing ) test_that("summarise_coding_tools missing data is handled correctly", { @@ -41,8 +41,8 @@ test_that("summarise_coding_tools knowledge output is as expected", { "SQL", "Stata", "VBA"), each=3), - "value" = factor(rep(c("Yes", "Don't Know", "No"), 8), - levels = c("Yes", "Don't Know", "No")), + "value" = factor(rep(c("Yes", "Don't know", "No"), 8), + levels = c("Yes", "Don't know", "No")), "n" = c(1/2, 1/6, 1/3, 1/2, 1/6, 1/3, 1/6, 1/2, 1/3, 1/3, 1/6, 1/2, 1/3, 1/6, 1/2, 1/2, 1/6, 1/3, 1/6, 1/2, 1/3, 1/6, 1/2, 1/3)) @@ -63,8 +63,8 @@ test_that("summarise_coding_tools access output is as expected", { "SQL", "Stata", "VBA"), each=3), - "value" = factor(rep(c("Yes", "Don't Know", "No"), 8), - levels = c("Yes", "Don't Know", "No")), + "value" = factor(rep(c("Yes", "Don't know", "No"), 8), + levels = c("Yes", "Don't know", "No")), "n" = c(1/6, 0, 5/6, 1/6, 1/3, 1/2, 1/3, 1/2, 1/6, 1/2, 1/3, 1/6, 1/2, 1/3, 1/6, 1/6, 1/3, 1/2, 1/3, 1/2, 1/6, 1/3, 1/2, 1/6)) diff --git a/tests/testthat/test-summarise_dep_man.R b/tests/testthat/test-summarise_dep_man.R index 4e6412b..e3d2481 100644 --- a/tests/testthat/test-summarise_dep_man.R +++ b/tests/testthat/test-summarise_dep_man.R @@ -2,7 +2,7 @@ dummy_data <- data.frame(dep_management = c(NA, rep("Yes", 2), rep("No", 3), - rep("I don't know", 4))) + rep("I don't know what dependency management is", 4))) test_that("summarise_dep_man validation works", { @@ -26,10 +26,10 @@ test_that("summarise_dep_man output is as expected", { expected <- data.frame(value = factor(c("Yes", "No", - "I don't know"), + "I don't know what dependency management is"), levels = c("Yes", "No", - "I don't know")), + "I don't know what dependency management is")), n = c(2/9, 1/3, 4/9)) expect_equal(got, expected) diff --git a/tests/testthat/test-summarise_languages_by_prof.R b/tests/testthat/test-summarise_languages_by_prof.R index e7ea49f..74b0045 100644 --- a/tests/testthat/test-summarise_languages_by_prof.R +++ b/tests/testthat/test-summarise_languages_by_prof.R @@ -4,7 +4,7 @@ knowledge_response <- rep(c( NA, "Yes", "No", - "Don't Know"), + "Don't know"), each = 3, times = 6) prof_response <- rep(c( diff --git a/tests/testthat/test-summarise_rep_workflow.R b/tests/testthat/test-summarise_rep_workflow.R index a65da99..6a653b7 100644 --- a/tests/testthat/test-summarise_rep_workflow.R +++ b/tests/testthat/test-summarise_rep_workflow.R @@ -4,7 +4,7 @@ dummy_data <- data.frame( NA, "Yes", "No", - "I don't know") + "I don't know what reproducible workflows are") ) @@ -25,10 +25,10 @@ test_that("summarise_rep_workflow output is as expected", { value = factor(c( "Yes", "No", - "I don't know"), + "I don't know what reproducible workflows are"), levels = c("Yes", "No", - "I don't know")), + "I don't know what reproducible workflows are")), n = rep(1/3, times = 3)