Skip to content

Commit

Permalink
unit test calcx for #6
Browse files Browse the repository at this point in the history
Former-commit-id: ce7b2b7
Former-commit-id: 42f5ce1
  • Loading branch information
alexvpickering committed May 9, 2019
1 parent d1ed134 commit 98f8385
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/testthat/test_calcx.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
context("Calculating x position of correlation value")

test_that("calcx return midpoint of width when correlation is 0", {
xpos <- calcx(0, width=200)
expect_equal(xpos, 100)
})

test_that("calcx without padding returns exactly devided values", {
expect_equal(calcx(-1, width=200, pad = 0), 0)
expect_equal(calcx(-0.5, width=200, pad = 0), 50)
expect_equal(calcx(0, width=200, pad = 0), 100)
expect_equal(calcx(0.5, width=200, pad = 0), 150)
expect_equal(calcx(1, width=200, pad = 0), 200)
})

test_that("calcx with padding avoids endpoints", {
expect_gt(calcx(-1), calcx(-1, pad = 0))
expect_lt(calcx(1), calcx(1, pad = 0))
})

0 comments on commit 98f8385

Please sign in to comment.