diff --git a/tests/testthat/test_analysis_example_bangertdrowns2004.r b/tests/testthat/test_analysis_example_bangertdrowns2004.r index 71f6483..bd705d2 100644 --- a/tests/testthat/test_analysis_example_bangertdrowns2004.r +++ b/tests/testthat/test_analysis_example_bangertdrowns2004.r @@ -1,6 +1,8 @@ -context("test-dat.bangertdrowns2004.R") -library(metadat) +context("Checking analysis example: bangertdrowns2004") + library(metafor) +source("tolerances.r") # read in tolerances + ### copy data into 'dat' and examine data dat <- dat.bangertdrowns2004 @@ -14,7 +16,7 @@ test_that("Returns rma object", { expect_is(res, "rma.uni") }) -test_that("Checks rma results", { +test_that("results are correct for the random-effects model.", { expect_identical(round(res$k, digits = 2), 48) expect_identical(round(as.numeric(res$beta[,1]), digits = 7), 0.2219296) expect_identical(round(as.numeric(res$tau2), digits = 7), 0.0499411) diff --git a/tests/testthat/test_analysis_example_barone2019.r b/tests/testthat/test_analysis_example_barone2019.r index d3a1272..ceaf35d 100644 --- a/tests/testthat/test_analysis_example_barone2019.r +++ b/tests/testthat/test_analysis_example_barone2019.r @@ -1,9 +1,10 @@ -context("test-dat.barone2019.R") +context("Checking analysis example: barone2019") + library(metadat) library(metafor) ## Make copy of dataset -dat <- dat.barone2019 +dat <- metadat::dat.barone2019 # First model res <- rma(yi=logit.p., sei = sei, data=dat, slab = paste(Author, Year)) @@ -13,7 +14,7 @@ test_that("Returns rma object", { expect_is(res, "rma.uni") }) -test_that("Checks rma results", { +test_that("results are correct for the random-effects model.", { expect_identical(round(res$k, digits = 2), 56) expect_identical(round(as.numeric(res$beta[,1]), digits = 7), 0.5662584) expect_identical(round(as.numeric(res$tau2), digits = 7), 0.4949573) diff --git a/tests/testthat/test_data_barone2019.R b/tests/testthat/test_data_barone2019.R new file mode 100644 index 0000000..29a6844 --- /dev/null +++ b/tests/testthat/test_data_barone2019.R @@ -0,0 +1,43 @@ +context("Checking data: barone2019") + +library(metadat) +library(metafor) +library(digest) + +## Make copy of dataset +dat <- metadat::dat.barone2019 + +test_that("checks data md5 hash", { + expect_match(digest(metadat::dat.barone2019, algo = "md5"), "44d1bfc0b736fc8c3846af9e0d81694b") +}) + +test_that('data dimensions are correct', { + expect_equal(ncol(dat), 22) + expect_equal(nrow(dat), 56) +}) + +test_that('data types are correct', { + expect_is(dat, 'data.frame') + expect_is(dat$id, 'character') + expect_is(dat$Author, 'character') + expect_is(dat$Year, 'integer') + expect_is(dat$Paradigm, 'character') + expect_is(dat$Measure, 'character') + expect_is(dat$Age_months, 'numeric') + expect_is(dat$n, 'integer') + expect_is(dat$Dropped_participants, 'integer') + expect_is(dat$Dropped_participants_corrected, 'integer') + expect_is(dat$Familiarization, 'integer') + expect_is(dat$Belief, 'character') + expect_is(dat$Agent, 'character') + expect_is(dat$Target_object_Presence, 'character') + expect_is(dat$Object_movements, 'integer') + expect_is(dat$Motive_transformation, 'character') + expect_is(dat$Salience_of_agents_MS, 'character') + expect_is(dat$Interaction, 'character') + expect_is(dat$Design, 'character') + expect_is(dat$Test_trials, 'integer') + expect_is(dat$logit.p., 'numeric') + expect_is(dat$vlogit.p., 'numeric') + expect_is(dat$sei, 'numeric') +}) \ No newline at end of file