library(testthat)
library(data.summary)
context("Check Numeric Vector")
test_that("Thrown Correct Errors", {
x <- data.frame(c(1,2),c(3,4))
expect_error(check_numeric_vector(x), "Data is not a single numeric vector")
y <- c()
expect_error(check_numeric_vector(y), "Vector is of length 0")
z <- 'hello'
expect_error(check_numeric_vector(z), "Given data is not numeric")
k <- c('a', 'b', 'c')
expect_error(check_numeric_vector(k), "Given data is not numeric")
l <- c(1, 'a')
expect_error(check_numeric_vector(l), "Given data is not numeric")
m <- NA
expect_error(check_numeric_vector(m), "Given data is not numeric")
})
test_that("Doesn't Throw Errors", {
x <- 1:10
expect_equal(check_numeric_vector(x), c())
y <- c(1, 4, 2, 0)
expect_equal(check_numeric_vector(y), c())
z <- rnorm(20)
expect_equal(check_numeric_vector(z), c())
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.