a statement that checks if something is true and if not prints a given error message and exits
stopifnot()
You may also be interested in packages like Runit and testthat for unit testing.