diff --git a/tests/testthat/test-load.lcms.R b/tests/testthat/test-load.lcms.R index 8bfae4a..0b026f9 100644 --- a/tests/testthat/test-load.lcms.R +++ b/tests/testthat/test-load.lcms.R @@ -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) ) ) \ No newline at end of file