ensure: Quick assertion function for sanity checking your code

View source: R/r_tools.R

ensureR Documentation

Quick assertion function for sanity checking your code

Description

This function can be used to do quick checks on your code, especially in RMarkdown analysis documents. For example, making sure that the number of rows in a dataframe hasn't changed after a left-join operation. For more than a handful of tests, look for a fuller testing package like assertr.

Usage

ensure(desc, expr)

Arguments

desc

(Character) Human-readable description of the expression being evaluated.

expr

(Expression) The expression being tested. It should evaluate to TRUE when the test passes, and FALSE when the test fails.

Value

An Error if the test fails, or a Message if the test passes.

Examples

## Not run: 
letters
length(letters)

ensure("There should be 26 letters", length(letters) == 26)

## End(Not run)


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.