Skip to content

Commit

Permalink
add unit test for function CreatePathwayCollection per issue #70
Browse files Browse the repository at this point in the history
  • Loading branch information
Lizhong Liu committed Mar 25, 2019
1 parent c12ef8d commit f3169e1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Suggests:
rmarkdown,
SummarizedExperiment,
survminer,
tidyverse
tidyverse,
testthat
biocViews:
CopyNumberVariation,
DNAMethylation,
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(pathwayPCA)

test_check("pathwayPCA")
44 changes: 44 additions & 0 deletions tests/testthat/test_CreatePathwayCollection.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
context("CreatePathwayCollection")

test_that("CreatePathwayCollection gives correct errors", {
expect_error(CreatePathwayCollection(
sets_ls = "pathway",
TERMS = "five",
setType = "pathway",
setsize = 1
),
"The sets_ls object must be a list of set membership vectors.")

expect_error(CreatePathwayCollection(
sets_ls = list(one = 1, five = 5),
TERMS = list(five = "five"),
setType = "pathway",
setsize = 1
),
"The TERMS object must be an atomic vector.")

expect_error(CreatePathwayCollection(
sets_ls = list(one = 1, five = 5),
TERMS = "five",
setType = "gene",
setsize = 1
),
"The TERMS vector must have the same length as the sets list.")
})

test_that("CreatePathwayCollection gives correct warnings", {
expect_warning(CreatePathwayCollection(
sets_ls = list(one = 1,
two = 1:2,
three = 1:3,
four = 1:4,
five = 1:5),
TERMS = c("one", "two", "three", "four", "five"),
setType = "gene",
setsize = 1
),
"The names 'setsize' and 'n_tested' are reserved names of a pathwayCollection object.
Values stored with these names may be overwritten during pathwayPCA function execution.
Use with extreme caution.")

})

0 comments on commit f3169e1

Please sign in to comment.