Skip to content

Commit

Permalink
add tests for plate builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Fersoil authored and Fersoil committed Jan 14, 2025
1 parent c3cd506 commit 16f78f5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/classes-plate_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,11 @@ get_location_matrix <- function(nrow = 8, ncol = 12, as_vector = FALSE) {
if (as_vector) {
return(all_locations)
}
all_location_matrix <- matrix(all_locations,
nrow = nrow,
ncol = ncol,
byrow = TRUE
return(
matrix(all_locations,
nrow = nrow,
ncol = ncol,
byrow = TRUE
)

Check warning on line 585 in R/classes-plate_builder.R

View check run for this annotation

Codecov / codecov/patch

R/classes-plate_builder.R#L580-L585

Added lines #L580 - L585 were not covered by tests
)
}
45 changes: 45 additions & 0 deletions tests/testthat/test-plate_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,48 @@ test_that("Handling of empty layout names", {
c("BLANK", "STANDARD CURVE", "POSITIVE CONTROL", "NEGATIVE CONTROL")
)
})

# Test setters for dilutions, sample types and sample names
test_that("Test setting dilutions", {
plate <- PlateBuilder$new(sample_names = c("S1", "S2", "S3", "S4"),
analyte_names = c("A1", "A2", "A3", "A4"))
plate$set_dilutions(FALSE, c("1/50", "1/100", "1/200", NA))
expect_equal(plate$dilutions, c("1/50", "1/100", "1/200", NA))


plate <- PlateBuilder$new(sample_names = c("S1", "S2", "S3", "S4"),
analyte_names = c("A1", "A2", "A3", "A4"))
plate$set_dilutions(TRUE, c("1/50", "1/100", "1/200", NA))
expect_equal(plate$dilutions, c("1/50", "1/100", "1/200", NA))


plate$dilutions <- NULL
expect_error(plate$set_dilutions(TRUE))
})


test_that("Test setting sample types", {
plate <- PlateBuilder$new(sample_names = c("S1", "S2", "S3", "S4"),
analyte_names = c("A1", "A2", "A3", "A4"))
plate$set_sample_types(FALSE, c("STANDARD CURVE", "NEGATIVE CONTROL", "POSITIVE CONTROL", "TEST"))
expect_equal(plate$sample_types, c("STANDARD CURVE", "NEGATIVE CONTROL", "POSITIVE CONTROL", "TEST"))

expect_error(plate$set_sample_types(FALSE, NULL))

plate <- PlateBuilder$new(sample_names = c("S1", "S2", "S3", "S4"),
analyte_names = c("A1", "A2", "A3", "A4"))
plate$set_sample_types(TRUE, c("STANDARD CURVE", "NEGATIVE CONTROL", "POSITIVE CONTROL", "TEST"))
expect_equal(plate$sample_types, c("STANDARD CURVE", "NEGATIVE CONTROL", "POSITIVE CONTROL", "TEST"))

expect_error(plate$set_sample_types(TRUE))
})


test_that("Test setting sample names", {
plate <- PlateBuilder$new(sample_names = c("S1", "S2", "S3", "S4"),
analyte_names = c("A1", "A2", "A3", "A4"))
plate$set_sample_names(FALSE)
expect_equal(plate$sample_names, c("S1", "S2", "S3", "S4"))

expect_error(plate$set_sample_names(TRUE))
})

0 comments on commit 16f78f5

Please sign in to comment.