Skip to content

Commit

Permalink
Added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
PratibhaPanwar committed Oct 30, 2024
1 parent 540d1db commit 374914b
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files

library(testthat)
library(clustSIGNAL)

test_check("clustSIGNAL")
66 changes: 66 additions & 0 deletions tests/testthat/test_conditions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# test_that("Checking dimensions of neighbours matrix", {
# data(example)
# cells <- "uniqueID"
# samples <- "sample_id"
# NN <- 30
# out <- clustSIGNAL::neighbourDetect(spe, samples, NN, cells,
# sort = TRUE)
#
# testthat::expect_equal(
# dim(out$nnCells),
# as.integer(c(ncol(spe), NN + 1))
# )
# })
#
# test_that("Checking neighbours detected for all cells", {
# data(example)
# cells <- "uniqueID"
# samples <- "sample_id"
# NN <- 30
# out <- clustSIGNAL::neighbourDetect(spe, samples, NN, cells,
# sort = TRUE)
#
# testthat::expect_identical(
# as.character(out$nnCells[, 1]),
# spe[[cells]]
# )
# })

test_that(
"Expecting error when wrong column name given for samples", {
data(example)
samples <- "wrongID"
cells <- "uniqueID"

testthat::expect_error(
suppressWarnings(clustSIGNAL(spe, samples, cells))
)
}
)

test_that(
"Expecting error when wrong column name given for cells", {
data(example)
samples <- "sample_id"
cells <- "wrongID"

testthat::expect_error(
suppressWarnings(clustSIGNAL(spe, samples, cells))
)
}
)

test_that(
"Expecting error when spatial coordinates missing", {
data(example)
samples <- "sample_id"
cells <- "uniqueID"
colData(spe) <- cbind(colData(spe), spatialCoords(spe))
spatialCoords(spe) <- NULL

testthat::expect_error(
suppressWarnings(clustSIGNAL(spe, samples, cells))
)
}
)

0 comments on commit 374914b

Please sign in to comment.