library(checkmate)
context("rRange")
test_that("output has class RasterLayer", {
input <- rtRasters$continuous
output <- rRange(obj = input, range = c(0, 10))
expect_class(output, "RasterLayer")
})
test_that("output is named", {
input <- rtRasters$continuous
output <- rRange(obj = input, range = c(0, 10))
expect_named(output)
})
test_that("output and input have same dimension", {
input <- rtRasters$continuous
dim1 <- dim(input)
output <- rRange(obj = input, range = c(0, 10))
expect_equal(dim(output), dim1)
})
test_that("Error if arguments have wrong value", {
input <- rtRasters$continuous
mat <- as.matrix(input)
expect_error(rRange(obj = "bla", range = c(0, 10)))
expect_error(rRange(obj = mat, range = c(0, 10)))
expect_error(rRange(obj = input, range = "bla"))
expect_error(rRange(obj = input, range = 1))
})
test_that("history is correct", {
input <- rtRasters$continuous
output <- rRange(obj = input, range = c(0, 10))
history <- output@history
expect_list(history, len = 2, types = "character")
input@history <- list("this object has a history")
output <- rRange(obj = input, range = c(0, 10))
history <- output@history
expect_list(history, len = 2, types = "character")
expect_true(history[[1]] == "this object has a history")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.