tests/testthat/test-insert_into.R

test_that("can add column at any position", {
    df1 <- data.frame(a = 3, b = 4, c = 5)
    df2 <- data.frame(X = 1, Y = 2)
    at_pos <- function(i) {
        insert_into(df1, df2, where = i)
    }

    expect_named(at_pos(1), c("X", "Y", "a", "b", "c"))
    expect_named(at_pos(2), c("a", "X", "Y", "b", "c"))
    expect_named(at_pos(3), c("a", "b", "X", "Y", "c"))
    expect_named(at_pos(4), c("a", "b", "c", "X", "Y"))
})
kelly-sovacool/foofactors documentation built on Jan. 28, 2020, 12:04 a.m.