Skip to content

Commit

Permalink
expanded test to mzdata and cover more parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
wverastegui committed Apr 17, 2024
1 parent 9c06255 commit e5aea30
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions tests/testthat/test-load.lcms.R
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)
)
)

0 comments on commit e5aea30

Please sign in to comment.