tests/testthat/test-threeway.R

context("Three-way")

test_that("Returns greater value", {
    expect_equal(1 %<=>% 2, 2)
    expect_equal(2 %<=>% 1, 2)
})

test_that("Works on vectors", {
    expect_equal(c(1, 2, 3) %<=>% c(2, 1, 3), c(2, 2, 0))
})

test_that(
    "Displays warning on different types",
    expect_warning(object = "a" %<=>% 1,
                   regexp = "Left\\sand\\sright.*")
)

test_that("Generates error for vectors of different lengths",
          expect_error(object = {
              a <- 1:3
              b <- 1:2
              a %<=>% b
          }))
konradedgar/KEmisc documentation built on April 15, 2021, 1:50 p.m.