[英]Negative conditions in testthat
是否可以在test_that()或Expect_XXX()調用中寫入否定條件? 具體來說,我想測試一個不包含子字符串的字符串,如下所示:
expect_that("Apples, Oranges, Banana", !matches('Onion'))
要么
expect_not_match("Apples, Oranges, Banana", 'Onion')
我知道我可以將Expect_true()與grep結合使用:
expect_true(length(grep("Onion", "Apples, Oranges, Banana")) == 0)
但這似乎不太可讀。
testthat::not
怎么樣?
expect_that("Apples, Oranges, Banana", not(matches('Onion')))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.