From b302019485561ec567a6a950262391ff9a8db92e Mon Sep 17 00:00:00 2001 From: Robin Lovelace Date: Mon, 9 Nov 2020 21:59:13 +0000 Subject: [PATCH] Add a simple test for #18 --- tests/testthat.R | 4 ++++ tests/testthat/test-slopes.R | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-slopes.R diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..b9a92ec --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(slopes) + +test_check("slopes") diff --git a/tests/testthat/test-slopes.R b/tests/testthat/test-slopes.R new file mode 100644 index 0000000..3833ba4 --- /dev/null +++ b/tests/testthat/test-slopes.R @@ -0,0 +1,6 @@ +test_that("slope_* functions work", { + x = c(0, 2, 3, 4, 5, 9) + e = c(1, 2, 2, 4, 3, 1) / 10 + expect_equal(slope_vector(x, e), c(0.05, 0, 0.2, -0.1, -0.05)) + # expect_equal(slope_distance(x, e), c(0.05, 0, 0.2, -0.1, -0.05)) +})