Nothing
# Data for tests ----
sites <- expand.grid("transect" = 1:5,
"quadrat" = 1:5)
nodes <- create_node_labels(data = sites,
transect = "transect",
quadrat = "quadrat")
sites_qu <- expand.grid("transect" = 3,
"quadrat" = 1:5)
nodes_qu <- create_node_labels(data = sites_qu,
transect = "transect",
quadrat = "quadrat")
sites_tr <- expand.grid("transect" = 1:5,
"quadrat" = 3)
nodes_tr <- create_node_labels(data = sites_tr,
transect = "transect",
quadrat = "quadrat")
# Tests for errors ----
test_that("bishop() - Tests for errors", {
expect_error(bishop(),
paste0("Argument 'nodes' is required (output of the function ",
"create_node_labels())"),
fixed = TRUE)
expect_error(bishop(nodes_qu),
paste0("The bishop movement is not designed to work through ",
"quadrats only. Please use pawn() instead."),
fixed = TRUE)
expect_error(bishop(nodes_tr),
paste0("The bishop movement is not designed to work through ",
"transects only. Please use fool() instead."),
fixed = TRUE)
})
# Tests for success ----
test_that("bishop() - Tests for success (2D network)", {
expect_silent({
neighbors <- bishop(nodes,
focus = "3-3",
degree = 1,
directed = TRUE,
reverse = FALSE,
self = FALSE)
})
expect_equal(class(neighbors), "data.frame")
expect_equal(ncol(neighbors), 4L)
expect_equal(nrow(neighbors), 2L)
expect_equal(neighbors[ , "node"], c("2-4", "4-4"))
expect_silent({
neighbors <- bishop(nodes,
focus = "3-3",
degree = 2,
directed = TRUE,
reverse = FALSE,
self = FALSE)
})
expect_equal(class(neighbors), "data.frame")
expect_equal(ncol(neighbors), 4L)
expect_equal(nrow(neighbors), 4L)
expect_equal(neighbors[ , "node"], c("1-5", "2-4", "4-4", "5-5"))
expect_silent({
neighbors <- bishop(nodes,
focus = "3-3",
degree = 1,
directed = TRUE,
reverse = TRUE,
self = FALSE)
})
expect_equal(class(neighbors), "data.frame")
expect_equal(ncol(neighbors), 4L)
expect_equal(nrow(neighbors), 2L)
expect_equal(neighbors[ , "node"], c("2-2", "4-2"))
expect_silent({
neighbors <- bishop(nodes,
focus = "3-3",
degree = 1,
directed = FALSE,
reverse = FALSE,
self = FALSE)
})
expect_equal(class(neighbors), "data.frame")
expect_equal(ncol(neighbors), 4L)
expect_equal(nrow(neighbors), 4L)
expect_equal(neighbors[ , "node"], c("2-2", "2-4", "4-2", "4-4"))
expect_silent({
neighbors <- bishop(nodes,
focus = "3-3",
degree = 1,
directed = FALSE,
reverse = FALSE,
self = TRUE)
})
expect_equal(class(neighbors), "data.frame")
expect_equal(ncol(neighbors), 4L)
expect_equal(nrow(neighbors), 5L)
expect_equal(neighbors[ , "node"], c("2-2", "2-4", "3-3", "4-2", "4-4"))
})
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.