Examples for 'testthat::logical-expectations'


Does code return 'TRUE' or 'FALSE'?

Aliases: logical-expectations expect_true expect_false

Keywords:

### ** Examples

expect_true(2 == 2)
Error in get(genname, envir = envir): object 'compare_proxy' not found
# Failed expectations will throw an error
## Not run: 
##D expect_true(2 != 2)
## End(Not run)
expect_true(!(2 != 2))
Error in get(genname, envir = envir): object 'compare_proxy' not found
# or better:
expect_false(2 != 2)
Error in get(genname, envir = envir): object 'compare_proxy' not found
a <- 1:3
expect_true(length(a) == 3)
Error in get(genname, envir = envir): object 'compare_proxy' not found
# but better to use more specific expectation, if available
expect_equal(length(a), 3)

[Package testthat version 3.1.4 Index]