Skip to content

Commit

Permalink
fix helper
Browse files Browse the repository at this point in the history
  • Loading branch information
egillax committed Feb 10, 2025
1 parent ccc7193 commit bd0a99f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Config/reticulate:
list(package = "torch"),
list(package = "polars"),
list(package = "duckdb"),
list(package = "pyarrow")
list(package = "pyarrow"),
list(package = "tqdm"),
list(package = "connectorx"),
list(package = "pynvml")
Expand Down
2 changes: 1 addition & 1 deletion R/HelperFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ checkIsClass <- function(parameter, classes) {
#' @param value which value it should be higher than
checkHigher <- function(parameter, value) {
name <- deparse(substitute(parameter))
if (!is.numeric(parameter) || all(parameter == value)) {
if (!is.numeric(parameter) || all(parameter <= value)) {
ParallelLogger::logError(paste0(name, " needs to be > ", value))
stop(paste0(name, " needs to be > ", value))
}
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-HelperFunctions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test_that("Helper functions", {
expect_true(checkInStringVector("test", c("test", "test2")))
expect_error(checkInStringVector("test", c("test2", "test3")))

local({
filePath <<- withr::local_tempfile(lines = "File contents")
expect_true(checkFileExists(filePath))
})
expect_error(checkFileExists(filePath))

# checkHigherEqual
expect_true(checkHigherEqual(2, 1))
expect_true(checkHigherEqual(1, 1))
expect_error(checkHigherEqual(0, 1))

# checkHigher
expect_true(checkHigher(2, 1))
expect_error(checkHigher(1, 1))
expect_error(checkHigher(0, 1))

# checkIsClass)
expect_true(checkIsClass(2, c("numeric", "integer")))
expect_error(checkIsClass(2, c("character")))
expect_error(checkIsClass("2", c("numeric", "integer")))
})

0 comments on commit bd0a99f

Please sign in to comment.