knitr::opts_chunk$set( error = TRUE, collapse = TRUE, comment = "#>", out.width = "100%" )
library(testthat) library(jeksterslabRutils) context("Test util_valid_email.")
valid <- "email@email.com" invalid <- "https://www.google.com" valid_expected <- TRUE invalid_expected <- FALSE Variable <- c( "`valid`", "`invalid`" ) Description <- c( paste0("Vaild email (", valid, ")."), paste0("Invalid email (", invalid, ").") ) Value <- c( valid_expected, invalid_expected ) knitr::kable( x = data.frame( Variable, Description, Value ), row.names = FALSE )
valid_result <- util_valid_email(x = valid) invalid_result <- util_valid_email(x = invalid)
Parameter <- c( valid_expected, invalid_expected ) Result <- c( valid_result, invalid_result ) knitr::kable( x = data.frame( Description, Parameter, Result ), row.names = FALSE )
test_that("util_valid_email returns TRUE", { expect_true( valid_result ) })
test_that("util_valid_email returns FALSE", { expect_false( invalid_result ) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.