From df7d9d942eb8bfd463d028392c963fb7aed72861 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 23 Feb 2024 16:08:56 +0100 Subject: [PATCH] tests --- tests/testthat/test-check_homogeneity.R | 32 +++++++++++++++++++++++-- tests/testthat/test-check_normality.R | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-check_homogeneity.R b/tests/testthat/test-check_homogeneity.R index 40bba5479..1b3fddbd9 100644 --- a/tests/testthat/test-check_homogeneity.R +++ b/tests/testthat/test-check_homogeneity.R @@ -21,9 +21,37 @@ test_that("check_homogeneity | afex", { expect_error(check_homogeneity(aW)) msg <- capture.output(expect_message(check_homogeneity(aB, method = "bartlett"), "Only")) - msg <- capture.output(pM <- check_homogeneity(aM)) - msg <- capture.output(pB <- check_homogeneity(aB)) + msg <- capture.output({ + pM <- check_homogeneity(aM) + }) + msg <- capture.output({ + pB <- check_homogeneity(aB) + }) expect_equal(pM, 0.3496516, ignore_attr = TRUE, tolerance = 0.001) expect_equal(pB, 0.3496516, ignore_attr = TRUE, tolerance = 0.001) }) + +test_that("check_homogeneity | t-test", { + data(mtcars) + expect_error( + check_homogeneity(t.test(mtcars$mpg, mtcars$hp, var.equal = FALSE)), + regex = "Test does not assume" + ) + + out <- t.test(mtcars$mpg, mtcars$hp, var.equal = TRUE) + expect_equal( + check_homogeneity(out), + structure( + 6.18792236963585e-121, + object_name = out, + method = "Bartlett Test", + class = c( + "check_homogeneity", + "see_check_homogeneity", "numeric" + ) + ), + tolerance = 1e-3, + ignore_attr = TRUE + ) +}) diff --git a/tests/testthat/test-check_normality.R b/tests/testthat/test-check_normality.R index 2eaed8a8c..d36516bf4 100644 --- a/tests/testthat/test-check_normality.R +++ b/tests/testthat/test-check_normality.R @@ -60,6 +60,7 @@ test_that("check_normality | glmmTMB", { test_that("check_normality | t-test", { + data(mtcars) out <- t.test(mtcars$mpg, mtcars$hp, var.equal = TRUE) expect_equal( check_normality(out),