tests/testthat/test-list_remove.R

describe("list_remove", {
    test_list <- generate_test_list()

    it("removes elements from a list", {
        in_len <- length(test_list)
        new_list <- list_remove(test_list, element_df1, 1, "abc")
        out_len <- length(new_list)
        expect_equal(out_len, in_len - 3)
        expect_false(any(c("element_df1", "abc") %in% names(new_list)))
    })

    it("throws an error if elements to be removed do not exit in the list", {
        expect_error(list_remove(test_list, "foo"))
    })
})

Try the listr package in your browser

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

listr documentation built on Oct. 6, 2022, 5:11 p.m.