#' ---
#' title: "Test: eval"
#' author: "Ivan Jacob Agaloos Pesigan"
#' date: "`r Sys.Date()`"
#' output: rmarkdown::html_vignette
#' vignette: >
#' %\VignetteIndexEntry{Test: eval}
#' %\VignetteEngine{knitr::rmarkdown}
#' %\VignetteEncoding{UTF-8}
#' ---
#'
#+ knitr_options, include=FALSE, cache=FALSE
knitr::opts_chunk$set(
error = TRUE,
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
#'
#+ setup
library(testthat)
library(jeksterslabRboot)
context("Test eval.")
#'
#+ results
result <- ci_eval(
ci = c(1, 3),
thetahat = 2,
theta = 2
)
#'
#' ## testthat
#'
#' Confidence interval contain zero.
#'
#+ testthat_01
test_that("TRUE", {
expect_true(
zero_hit(
lo = -1,
up = 1
),
theta_hit(
lo = -1,
theta = 0,
up = 1
)
)
})
#'
#' Confidence interval does not contain zero.
#'
#+ testthat_02
test_that("FALSE", {
expect_false(
zero_hit(
lo = 1,
up = 2
),
theta_hit(
lo = 1,
theta = 0,
up = 2
)
)
})
#'
#+ testthat_03
test_that("1", {
expect_equal(
len(
lo = 1,
up = 2
),
shape(
lo = -1,
thetahat = 0,
up = 1
),
1
)
})
#'
#' `ci_eval`
#'
#+ testthat_04
test_that("zero_hit", {
expect_false(
as.logical(result[1])
)
})
#'
#+ testthat_05
test_that("theta_hit", {
expect_true(
as.logical(result[2])
)
})
#'
#+ testthat_06
test_that("len", {
expect_equivalent(
result[3],
2
)
})
#'
#+ testthat_07
test_that("shape", {
expect_equivalent(
result[4],
1
)
})
#'
#+ testthat_08
test_that("message", {
expect_message(
ci_eval(
ci = c(0, 1, 2, 3),
thetahat = 2,
theta = 2,
label = "wrong length"
)
)
})
#'
#+ testthat_09
test_that("error", {
expect_error(
ci_eval(
ci = 1,
thetahat = 2,
theta = 2
)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.