tests/testthat/test-pvector.R

test_that("pvector object is working", {
    pv <- pvector$new(c(1,2,3,4,5))
    expect_is(pv, "pvector")
    expect_is(pv, "R6")
    popped <- pv$pop()
    expect_equal(popped, 1)
    expect_output(print(pv))
    expect_equal(pv$values, c(2,3,4,5))
    expect_equal(pv$length(), 4)
    pv$push(6)
    pv$push(c(7,8))
    expect_output(print(pv))
    expect_equal(pv$values, c(2,3,4,5,6,7,8))
    pv <- pvector$new(c(1,2))
    popped <- pv$pop()
    popped <- pv$pop()
    expect_equal(pv$length(), 0)
    popped <- pv$pop()
    expect_null(popped)
    expect_equal(pv$length(), 0)
})

Try the hypeR package in your browser

Any scripts or data that you put into this service are public.

hypeR documentation built on Nov. 8, 2020, 8:19 p.m.