tests/testthat/test-my_t.R

test_that("alternative is usable", {
  expect_error(my_t.test(rnorm(100, 0, 1), "dog", 3),
        "The alternative hypothesis must be 'two.sided', 'less', or 'greater'.")
})

test_that("two.sided works", {
  set.seed(123)
  x <- rnorm(100, 0, 1)
  response <- list(test_stat = 0.99040684, df = 99, alternative = "two.sided",
                   p_val = 0.32438981)
  expect_equal(my_t.test(x, "two.sided", 0), response)
})

test_that("less works", {
  set.seed(123)
  x <- rnorm(100, 0, 1)
  response <- list(test_stat = 0.99040684, df = 99, alternative = "less",
                   p_val = 0.8378051)
  expect_equal(my_t.test(x, "less", 0), response)
})

test_that("greater works", {
  set.seed(123)
  x <- rnorm(100, 0, 1)
  response <- list(test_stat = 0.99040684, df = 99, alternative = "greater",
                   p_val = 0.162194906)
  expect_equal(my_t.test(x, "greater", 0), response)
})
CamSims/myfirstpackage documentation built on Dec. 17, 2021, 1:56 p.m.