Skip to content

Commit

Permalink
fixing tests for anlz_fibmatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Sep 25, 2024
1 parent e4d9c2d commit 7291957
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/testthat/test-anlz_fibmatrix.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("Checking anlz_fibmatrix tibble class", {
result <- expect_warning(anlz_fibmatrix(fibdata, indic = 'fcolif'))
result <- anlz_fibmatrix(fibdata, indic = 'fcolif')
expect_is(result, 'tbl')
})

Expand Down Expand Up @@ -27,32 +27,32 @@ fibdatatst <- data.frame(
)

test_that("anlz_fibmatrix returns correct structure", {
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif')
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif', stas = c("a", "b", "c"))
expect_s3_class(result, "tbl_df")
expect_true(all(c("yr", "station", "gmean", "cat") %in% names(result)))
expect_true(all(c("yr", "grp", "gmean", "cat") %in% names(result)))
})

test_that("anlz_fibmatrix handles default parameters", {
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif')
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif', stas = c("a", "b", "c"))
expect_true(nrow(result) > 0)
expect_true(all(result$yr >= 2000 & result$yr <= 2005))
})

test_that("anlz_fibmatrix respects custom year range and stations", {
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif', yrrng = c(2001, 2004), stas = c("a", "b"))
expect_true(all(result$yr >= 2001 & result$yr <= 2004))
expect_true(all(result$station %in% c("a", "b")))
expect_true(all(result$grp %in% c("a", "b")))
})

test_that("anlz_fibmatrix works with different indicators", {
result_fcolif <- anlz_fibmatrix(fibdatatst, indic = "fcolif")
result_entero <- anlz_fibmatrix(fibdatatst, indic = "entero")
result_fcolif <- anlz_fibmatrix(fibdatatst, indic = "fcolif", stas = c('a', 'b', 'c'))
result_entero <- anlz_fibmatrix(fibdatatst, indic = "entero", stas = c('a', 'b', 'c'))
expect_true(nrow(result_fcolif) > 0)
expect_true(nrow(result_entero) > 0)
})

test_that("anlz_fibmatrix respects custom thresholds", {
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif', threshold = 200)
result <- anlz_fibmatrix(fibdatatst, indic = 'fcolif', threshold = 200, stas = c('a', 'b', 'c'))
expect_true(nrow(result) > 0)
})

Expand Down

0 comments on commit 7291957

Please sign in to comment.