From 305674dffc7eaeb22aec880210bae2d7a6f9e848 Mon Sep 17 00:00:00 2001 From: hejtmy Date: Fri, 23 Aug 2019 23:23:14 +0200 Subject: [PATCH] Hopefully fixes erroring travis --- .travis.yml | 2 ++ tests/testthat/test-preprocessing.R | 7 ------- tests/testthat/test-search-onset.R | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 tests/testthat/test-search-onset.R diff --git a/.travis.yml b/.travis.yml index 8c98c82..5096067 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,7 @@ cache: packages warnings_are_errors: false +r_packages: gifski + after_success: - Rscript -e 'covr::codecov()' diff --git a/tests/testthat/test-preprocessing.R b/tests/testthat/test-preprocessing.R index d9918fe..cf95caa 100644 --- a/tests/testthat/test-preprocessing.R +++ b/tests/testthat/test-preprocessing.R @@ -51,10 +51,3 @@ test_that("tests removal of unreal speeds", { expect_equal(obj_speed, obj_speed_2) }) -test_that("testing search onset", { - -}) - -test_that("testing search stops", { - -}) diff --git a/tests/testthat/test-search-onset.R b/tests/testthat/test-search-onset.R new file mode 100644 index 0000000..0745f3c --- /dev/null +++ b/tests/testthat/test-search-onset.R @@ -0,0 +1,28 @@ +context("Onset searching") +obj <- navr_object_preprocessed +obj <- remove_unreal_speeds(obj, type = "std", cutoff = 3, total_recalculate = T) +obj <- smooth_speed(obj, type = "median", points = 11) + +test_that("testing search onset", { + expect_silent(ls <- search_onsets(obj, speed_threshold = 5, min_duration = 2)) + expect_gt(length(ls$time_since_start), 0) + expect_silent(ls <- search_onsets(obj, speed_threshold = 5, min_duration = 2, still_duration = 2)) + expect_gt(length(ls$time_since_start), 0) + expect_silent(ls2 <- search_onsets(obj, speed_threshold = 5, min_duration = 2, still_speed_threshold = 5, still_duration = 2)) + expect_equal(ls, ls2) + expect_silent(ls <- search_onsets(obj, speed_threshold = 500, min_duration = 2, still_duration = 2)) + expect_length(ls$time_since_start, 0) + expect_silent(ls <- search_onsets(obj, speed_threshold = 1, min_duration = 200)) + expect_length(ls$time_since_start, 0) + expect_silent(ls <- search_onsets(obj, speed_threshold = 1, min_duration = 1, still_duration = 200)) + expect_length(ls$time_since_start, 0) +}) + +test_that("testing search stops", { + expect_silent(ls <- search_stops(obj, speed_threshold = 5, min_duration = 2)) + expect_gt(length(ls$time_since_start), 0) + expect_silent(ls <- search_stops(obj, speed_threshold = 0, min_duration = 0)) + expect_length(ls$time_since_start, 0) + expect_silent(ls <- search_stops(obj, speed_threshold = 1, min_duration = 1000)) + expect_length(ls$time_since_start, 0) +})