aboutsummaryrefslogtreecommitdiff
path: root/pkg/tests/testthat/test_TOXSWA_cwa.R
blob: 582c51e05d19406590eccc2bc1b2b28f5602eef3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(pfm)
context("Read and analyse TOXSWA cwa files")

test_that("TOXSWA cwa file is correctly read", {
  H_sw_D4_pond  <- read.TOXSWA_cwa("00001p_pa.cwa",
                                   basedir = "SwashProjects/project_H_sw/TOXSWA",
                                   zipfile = system.file("testdata/SwashProjects.zip",
                                               package = "pfm"))
  H_sw_D4_pond$zipfile <- NULL # do not test the path
  expect_equal_to_reference(H_sw_D4_pond, file = "H_sw_D4_pond.rds")
})

test_that("Getting events and moving window analysis works", {
  H_sw_R1_stream  <- read.TOXSWA_cwa("00003s_pa.cwa",
                                   basedir = "SwashProjects/project_H_sw/TOXSWA",
                                   zipfile = system.file("testdata/SwashProjects.zip",
                                               package = "pfm"))

  # Event analysis with two different thresholds
  H_sw_R1_stream$get_events(c(2, 10))
  expect_equal_to_reference(H_sw_R1_stream$events, file = "H_sw_R1_stream_events.rds")

  # Moving window analysis
  H_sw_R1_stream$moving_windows(c(7, 21))
  expect_equal_to_reference(H_sw_R1_stream$windows, file = "H_sw_R1_stream_windows.rds")
})

Contact - Imprint