inst/tinytest/test_minmax.R

z <- integer(0)
expect_true(is.null(minmax(z)))
expect_equal(minmax(z, empty_result = c(-Inf, Inf)), c(-Inf, Inf))

x <- logical(3)
expect_equal(minmax(x), c(FALSE, FALSE))
x <- !logical(3)
expect_equal(minmax(x), c(TRUE, TRUE))
x <- c(TRUE, FALSE, FALSE)
expect_equal(minmax(x), c(FALSE, TRUE))
x <- c(FALSE, TRUE)
expect_equal(minmax(x), c(FALSE, TRUE))
x <- sample(100)
expect_equal(minmax(x), c(1, 100))
x <- c(NaN, x)
expect_equal(minmax(x), c(1, 100))
x <- as.double(x)
expect_equal(minmax(x), c(1, 100))
x <- letters
expect_equal(minmax(x), c("a", "z"))

x <- as.raw(1:250)
expect_equal(minmax(x), c(as.raw(1L), as.raw(250L)))
x <- charToRaw("The quick brown fox jumps")
expect_equal(minmax(x), as.raw(range(as.integer(x))))

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.