Skip to content

Commit

Permalink
Add unit test for DEqual throws an error for non-dataframe input
Browse files Browse the repository at this point in the history
  • Loading branch information
HediaTnani committed Jan 9, 2024
1 parent 22a98f0 commit 1c3c6b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/DEqual.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ DEqual <- function(DE) {
# stopifnot(!is.null(rownames(DE)))

# Check if input is a dataframe
if (!is.data.frame(DE)) { stop("Error: The input is not a dataframe") }
if (!is.data.frame(DE)) { stop("Error: The input to DEqual is not a dataframe.") }

# Check if 't' is in the column names of DE
if (!("t" %in% colnames(DE))) {
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-DEqual.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ test_that("Input to DEqual is a dataframe", {
# Test if the input to DEqual is a dataframe
expect_true(is.data.frame(random_de), "The input to DEqual is not a dataframe.")
})

# Test if DEqual throws an error when input is not a dataframe
test_that("DEqual throws an error for non-dataframe input", {
# Test if DEqual throws an error when input is not a dataframe
expect_error(DEqual(covComb_tx_deg), "Error: The input to DEqual is not a dataframe.")
})

# Test that the output is a ggplot object
test_that("output is a ggplot", {
Expand Down

0 comments on commit 1c3c6b9

Please sign in to comment.