tests/testthat/test-my_t_test.R

test_that("my_t_test outputs a list", {
  expect_is(my_t_test(1:20, "less", 15),"list")
})
test_that("my_t_test works matematically", {
  test <- t.test(1:20, alternative = "two.sided", mu = 18)
  comparason <- unname(list(unname(test[[1]]),
                              unname(test[[2]]),
                              test[[8]],
                              test[[3]]
                              )
                       )
  expect_equal(unname(my_t_test(1:20, "two.sided", 18)),comparason)
})
test_that("my_t_test outputs error when icorrect parameter is used", {
  expect_error(my_t_test("one.sided", "greater", "three.sided"))
})
test_that("my_t_test outputs error wrong alternative is used", {
  expect_warning(my_t_test(1:20, "one.sided", 15))
})
MatteVin/myfirstpackage documentation built on March 20, 2020, 9:45 p.m.