Nothing
#context "test-squish")
# test_that("squish works", {
x <- c(0, 1, 1.5, 2.2)
expect_equal(max(squish(x, 0, 2)), 2)
expect_equal(max(squish(x, 0, 3)), max(x))
expect_equal(min(squish(x, 0, 3)), 0)
expect_equal(min(squish(x, -1, 3)), 0)
expect_equal(min(squish(x, 1.5, 3)), 1.5)
xi <- sample(1:10)
expect_identical(squish(xi, 1L, 10L), xi)
expect_identical(squish(xi, 1L, 1L), rep_len(1L, 10L))
expect_identical(squish(xi, 1L, 1L), rep_len(1L, 10L))
expect_identical(min(squish(xi, 5L, 6L)), 5L)
# test_that("Error handling", {
expect_error(squish(1:5, 1:2, 1),
pattern = "`length\\(a\\) = 2`, but must be length-one\\.")
expect_error(squish(1:5, 1, integer(0)),
pattern = "`length\\(b\\) = 0`, but must be length-one\\.")
expect_error(squish(1:5, 1L, 2L, in_place = "foo"),
pattern = "`in_place` was type character but must be logical.")
expect_error(squish(1:5, 1, 2), pattern = "type integer")
expect_error(squish("a", "a", "b"), "`x` was type character")
# test_that("Corner cases", {
expect_identical(squish(NULL), NULL)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.