inst/tinytest/test-xor2.R

# test_that("xor2 works", {
  x <- c(TRUE, FALSE)
  y <- c(FALSE, TRUE)
  u <- c(TRUE, TRUE, FALSE, FALSE, NA, NA)
  w <- c(TRUE, FALSE, NA, TRUE, FALSE, NA)
  z <- c(TRUE, FALSE, FALSE, TRUE, FALSE, TRUE)
  expect_equal(xor(x, y), xor2(x, y))
  expect_equal(xor(x, y), xor2(x, y, FALSE))
  expect_equal(xor(x, y), xor2(x, y, FALSE, FALSE))
  expect_equal(xor(x, y), xor2(x, y, anyNAy = FALSE))
  expect_equal(xor(u, w), xor2(u, w))
  expect_equal(xor(u, w), xor2(u, w, anyNA(u), anyNA(w)))
  expect_equal(xor(u, z), xor2(u, z, anyNA(u), anyNA(z)))
  expect_equal(xor(z, u), xor2(z, u, anyNA(z), anyNA(u)))

Try the hutilscpp package in your browser

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

hutilscpp documentation built on Oct. 11, 2023, 9:06 a.m.