tests/testthat/test_setwrapper.R

library(testthat)

context("SetWrapper")

test_that("construction", {
  expect_error(SetWrapper$new(), "SetWrapper is an abstract")
})

# test_that("accessors",{
#   u = Set$new(1) + Interval$new(3, 4)
#   # expect_equal(u$class, "numeric")
# })

test_that("equals", {
  u <- Set$new(1) + Interval$new(3, 4)
  expect_true(u$equals(Set$new(1) + Interval$new(3, 4)))
  expect_false(u$equals(Set$new(2) + Interval$new(3, 4)))
  expect_false((Set$new(1, 2) * Interval$new(1, 2))$equals((Set$new(1, 2) * Interval$new(1, 2)) * Interval$new(5, 6)))
  expect_false(u$equals(Set$new(1) * Interval$new(2)))
})

test_that("subset/complement", {
  u <- Set$new(1) + Interval$new(3, 4)
  expect_message(u$isSubset(Set$new(1)))
  expect_error(setcomplement(u), "y is missing")
})

Try the set6 package in your browser

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

set6 documentation built on Oct. 18, 2021, 5:06 p.m.