tests/testthat/test-rep.R

context("Test rep_*")

x <- matrix(1:4, nrow = 2)

test_that("Repeat rows correctly repeats the rows of a matrix", {
  expect_equal(
    rep_rows(x, 2),
    structure(
      c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L),
      .Dim = c(4L, 2L)
    )
  )
})

test_that("Repeat columns correctly repeats the columns of a matrix", {
  expect_equal(
    rep_cols(x, 2),
    structure(
      c(1L, 2L, 1L, 2L, 3L, 4L, 3L, 4L),
      .Dim = c(2L, 4L)
    )
  )
})
edsandorf/gizmo documentation built on Oct. 7, 2022, 3:45 p.m.