tests/testthat/test-wavelet-ECG-main.R

library("hfmAnnotation")
library("magrittr")
library("purrr")
library("testthat")
library("stats")
library("assertthat")
library("seewave")

context("wavelet-ECG-annotation with constant zero input signal")

ecg <- rep(0, 60000)
sampling_frequency <- 250

test_that("wavelet-ECG-annotation won't crash", {
  wavelet_ECG_annotation(ecg, sampling_frequency) %>%
    expect_error(NA)
})

test_that("wavelet-ECG-annotation returns no R-peak", {
  wavelet_ECG_annotation(ecg, sampling_frequency) %>%
    extract2("R_peak") %>%
    expect_equal(c())
})

test_that("wavelet-ECG-annotation returns no Q-wave", {
  wavelet_ECG_annotation(ecg, sampling_frequency) %>%
    extract2("Q_peak") %>%
    expect_equal(c())
})


context("wavelet-ECG-annotation with constant non-zero input signal")

ecg <- rep(10, 60000)
sampling_frequency <- 250

test_that("wavelet-ECG-annotation won't crash", {
  wavelet_ECG_annotation(ecg, sampling_frequency) %>%
    expect_error(NA)
})

test_that("wavelet-ECG-annotation returns no R-peak", {
  wavelet_ECG_annotation(ecg, sampling_frequency) %>%
    extract2("R_peak") %>%
    expect_equal(c())
})

test_that("wavelet-ECG-annotation returns no Q-wave", {
  wavelet_ECG_annotation(ecg, sampling_frequency) %>%
    extract2("Q_peak") %>%
    expect_equal(c())
})
Teresa00/hfmAnnotation documentation built on May 14, 2019, 12:51 a.m.