How can I test that the output of a function does not contain a certain string? I have tried to do this with testthat::expect_output()
, but to no avail so far. E.g. something like
expect_output(str(iris[c("Species", "Sepal.Length")]), "(?!Petal)", perl = TRUE)
ought to succeed (which it does), whereas something like
expect_output(str(iris[c("Species", "Sepal.Length")]), "(?!Sepal)", perl = TRUE)
ought to fail (which it does not).
Obviously the regex is not correct, yet.