tests/testthat/test-rem_reps.R

# Test cases for rem_reps function
test_that("rem_reps removes replicates", {

  # Call rem_reps function
  rem_reps_dat <- rem_reps(nut)
  
  # Check if the replicates are removed and averaged by day
  expect_equal(nrow(rem_reps_dat), 140)
  expect_s3_class(rem_reps_dat, 'swmpr')
  
})

# check rem_reps function
test_that("rem_reps removes replicates with user input function", {
  
  func <- function(x) max(x, na.rm = TRUE)
  rem_reps_dat <- rem_reps(nut, FUN = func)
  
  # Check if the replicates are removed
  expect_equal(nrow(rem_reps_dat), 140)
  expect_s3_class(rem_reps_dat, 'swmpr')
  
})


test_that("rem_reps returns error if not nutrients input", {
  
  # test error
  expect_error(rem_reps(wq), 'Input swmpr object must be nutrient data')
  
})

# rem_reps warning if not nutrient data
test_that("rem_reps returns warning if qaqc columns present", {
  
  # test warning
  expect_warning(rem_reps(apacpnut), 'QAQC columns present, removed from output')
  
})

Try the SWMPr package in your browser

Any scripts or data that you put into this service are public.

SWMPr documentation built on July 26, 2023, 5:20 p.m.