Expectation predicate for testing based on comparisons

expect_lt(current, target, ..., info = NA_character_)

expect_lte(current, target, ..., info = NA_character_)

expect_gt(current, target, ..., info = NA_character_)

expect_gte(current, target, ..., info = NA_character_)

Arguments

current

[R object or expression] Object or expression to be tested

target

[R object or expression] Expected outcome

...

Ignored

info

[character(1L)] Optional user-defined message; must be a single string value

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

Examples

# Expect strictly less than
expect_lt(1L, 3L) # Pass
#> ----- PASSED      : <-->
#>  call| expect_lt(1, 3) 
expect_lt(3L, 1L) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_lt(3, 1)
#>  diff| Expected 3 to be strictly less than 1 
expect_lt(1L, 1L) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_lt(1, 1)
#>  diff| Expected 1 to be strictly less than 1 

# Expect less than or equal to
expect_lte(1L, 3L) # Pass
#> ----- PASSED      : <-->
#>  call| expect_lte(1, 3) 
expect_lte(3L, 1L) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_lte(3, 1)
#>  diff| Expected 3 to be less than or equal to 1 
expect_lte(1L, 1L) # Pass
#> ----- PASSED      : <-->
#>  call| expect_lte(1, 1) 

# Expect strictly greater than
expect_gt(1L, 3L) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_gt(1, 3)
#>  diff| Expected 1 to be strictly greater than 3 
expect_gt(3L, 1L) # Pass
#> ----- PASSED      : <-->
#>  call| expect_gt(3, 1) 
expect_gt(1L, 1L) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_gt(1, 1)
#>  diff| Expected 1 to be strictly greater than 1 

# Expect greater than or equal to
expect_gte(1L, 3L) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_gte(1, 3)
#>  diff| Expected 1 to be greater than or equal to 3 
expect_gte(3L, 1L) # Pass
#> ----- PASSED      : <-->
#>  call| expect_gte(3, 1) 
expect_gte(1L, 1L) # Pass
#> ----- PASSED      : <-->
#>  call| expect_gte(1, 1)