expect isOfMagnitude

Share:

Description

expect_true that current is within interval of +-magnitude around target

Usage

1
2
expect_isOfMagnitude(target, current, orderOfMagnitudes = 1/2, 
    ...)

Arguments

target

numeric vector

current

numeric vector (recyled) of the same length as target

orderOfMagnitudes

see details

...

further arguments passed to expect_true

Details

in range 10^{ log10(current)+-orderOfMagnitudes }

Value

TRUE or error

Author(s)

Thomas Wutzler

See Also

twMisc expect_isInInterval

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
tmp <- if( requireNamespace("testthat") ){
    target=1e4
    expect_isOfMagnitude(1e4, 3e4)    #TRUE
    #try(expect_isOfMagnitude(1e4, 6e4))   #error
    expect_isOfMagnitude(1e4, 5000)   #TRUE
    #try(expect_isOfMagnitude(1e4, 2000))  #error
    
    expect_isOfMagnitude(1e-4, 3e-4)  #TRUE
    #try(expect_isOfMagnitude(1e-4, 6e-4)) #error
    expect_isOfMagnitude(1e-4, 5e-5)  #TRUE
    #try(expect_isOfMagnitude(1e-4, 2e-5)) #error
}

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.