forked from tianwei-yu/apLCMS
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expanded test to mzdata and cover more parameters
- Loading branch information
1 parent
9c06255
commit e5aea30
Showing
1 changed file
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
create_test_case <- function(filename, mz_length, rt_length, intensities_length) { | ||
list( | ||
filename = filename, | ||
expected_type = "list", | ||
expected_lengths = c(mz = mz_length, rt = rt_length, intensities = intensities_length), | ||
expected_num_na = c(mz = 0, rt = 0, intensities = 0) | ||
) | ||
} | ||
|
||
patrick::with_parameters_test_that( | ||
"test load.lcms reads mzML file", | ||
"test load.lcms reads different file types", | ||
{ | ||
# Arrange: Set up test inputs | ||
testdata <- file.path("..", "testdata") | ||
input_path <- file.path(testdata, filename) | ||
input_path <- file.path(testdata, "input", filename) | ||
|
||
# Act: Execute the function with the test inputs | ||
sut <- load.lcms(input_path) | ||
data <- recetox.aplcms::load.lcms(input_path) | ||
|
||
# Assert: Verify the function output matches expected results | ||
# Check that the function returns an object of the expected type | ||
testthat::expect_s3_class(sut, "tbl_df") | ||
actual_type <- data | ||
testthat::expect_type(actual_type, expected_type) | ||
|
||
# Check the lengths of the vectors in the list | ||
actual_lengths <- lengths(data) | ||
testthat::expect_equal(actual_lengths, expected_lengths) | ||
|
||
# Check the number of NA values in each vector | ||
actual_num_na <- sapply(data, function(x) sum(is.na(x))) | ||
testthat::expect_equal(actual_num_na, expected_num_na) | ||
}, | ||
|
||
patrick::cases( | ||
test_case_1 = list( | ||
filename = c("mbr_test0_copy.mzml") | ||
), | ||
test_case_2 = list( | ||
filename = c("test0_copy.mzxml") | ||
) | ||
test_case_1 = create_test_case("RCX_06_shortened.mzML", 879476, 879476, 879476), | ||
test_case_2 = create_test_case("test_file.mzXML", 9647575, 9647575, 9647575), | ||
test_case_3 = create_test_case("alg3.mzdata", 543894, 543894, 543894) | ||
) | ||
) |