tests/testthat/test-classdf.r

context('Checking that classdf returns the right type, the correct number of elements')

test_that('classdf returns lists and vectors as appropriate', {
    expect_is(classdf(CO2), 'list')
    expect_is(classdf(iris), 'character')
    expect_is(classdf(mtcars), 'character')
})

test_that('classdf returns the correct number of elements', {
    expect_equal(length(classdf(CO2)), length(CO2))
    expect_equal(length(classdf(iris)), length(iris))
    expect_equal(length(classdf(mtcars)), length(mtcars))
})

test_that('classdf returns a named object', {
    expect_named(classdf(CO2))
    expect_named(classdf(iris))
    expect_named(classdf(mtcars))
})

test_that('classdf returns an error if data is not a data.frame', {
    expect_error(classdf(list(A=1:3, B=2)))
})

Try the useful package in your browser

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

useful documentation built on Oct. 24, 2023, 9:07 a.m.