tests/testthat/test-reRank.R

context("Re-ranking rankLocReg")

test_that("Simple corner cases", {
    x  <-  sort(rnorm(100))
    y  <-  2 + 4*x + rnorm(100)
    z  <-  rankLocReg(xall=x, yall=y, alpha=0.8, method='eq')
    r  <-  reRank(z, newMethod='pc')
    n  <-  reRank(z, newMethod='z')
    w  <-  rankLocReg(xall=x, yall=y, alpha=0.8)
    v  <-  reRank(w, 'eq')
    expect_is(r, class(z))
    expect_is(n, class(r))
    expect_is(r$call, 'call')
    expect_is(n$call, 'call')
    expect_false(z$method == r$method)
    expect_false(n$method == z$method)
    expect_false(z$call == r$call)
    expect_true(z$method == 'eq')
    expect_true(r$method == 'pc')
    expect_true(n$method == 'z')
    expect_error(reRank(z), 'argument "newMethod" is missing, with no default')
    expect_error(reRank(x), 'x must be of class rankLocReg')
    expect_error(reRank(NULL), 'x must be of class rankLocReg')
    expect_is(w$call$method, 'NULL')
    expect_true(v$call$method == 'eq')
    expect_error(reRank(w, 'z'), 'z is already in place')
})
colin-olito/LoLinR documentation built on May 13, 2019, 9:54 p.m.