lundi 4 mai 2015

Negative conditions in testthat

Is it possible to write negative conditions in test_that() or expect_XXX() calls? Specifically I'd like to test for a string which does not contain a substring, so something like:

expect_that("Apples, Oranges, Banana", !matches('Onion'))

or

expect_not_match("Apples, Oranges, Banana", 'Onion')

I'm aware that I can use expect_true() in combination with e.g. grep:

expect_true(length(grep("Onion", "Apples, Oranges, Banana")) == 0)

But that doesn't seem too readable.

Aucun commentaire:

Enregistrer un commentaire