expect_isOfMagnitude: expect isOfMagnitude

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/testthat.R

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
}

twMisc documentation built on May 2, 2019, 6:11 p.m.