tests/testthat/test-infix.R

# Very basic tests. There's not much to do here.

test_that("Infix ops work.", {
  for (i in 1:5) {
    lhs <- runif(100+as.integer(runif(1, -10, 10)), 2**-30, 2**30)
    rhs <- runif(100, 2**-30, 2**30)
    expect_equal(lhs %|% rhs, bitwOr(lhs, rhs))
    expect_equal(lhs %&% rhs, bitwAnd(lhs, rhs))
    expect_equal(lhs %^% rhs, bitwXor(lhs, rhs))
    expect_equal(lhs %<<% 1:31, bitwShiftL(lhs, 1:31))
    expect_equal(lhs %>>% 1:31, bitwShiftR(lhs, 1:31))
  }
})

Try the vectorbitops package in your browser

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

vectorbitops documentation built on May 29, 2024, 1:18 a.m.