Skip to content

Commit 5e48854

Browse files
author
Jordan S Read
committed
adding tests
1 parent 5312b1a commit 5e48854

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/testthat/test-arguments.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@ test_that("setting params with other default works as expected",{
77
test_that("setting params with class match works as expected",{
88
expect_is(gsplot:::function_args("grDevices","points", x~y, use.default='xy.coords')[[1]],
99
'formula')
10+
})
11+
12+
context("is gsplot")
13+
14+
test_that("is gsplot",{
15+
16+
expect_true(is.gsplot(gsplot()))
17+
1018
})

tests/testthat/tests-abline.R

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
context("abline")
2+
3+
test_that("abline",{
4+
5+
## Setup up coordinate system (with x == y aspect ratio):
6+
plot(c(-2,3), c(-1,5), type = "n", xlab = "x", ylab = "y", asp = 1)
7+
## the x- and y-axis, and an integer grid
8+
abline(h = 0, v = 0, col = "gray60")
9+
10+
})
11+
12+
test_that("abline gsplot",{
13+
gs = points(gsplot(), c(-2,3), c(-1,5)) %>%
14+
abline(h = 0, v = 0, col = "gray60")
15+
expect_equal(names(gs$view), c("points","abline","window"))
16+
})
17+
18+
test_that("segments",{
19+
x <- stats::runif(12); y <- stats::rnorm(12)
20+
i <- order(x, y); x <- x[i]; y <- y[i]
21+
plot(x, y, main = "arrows(.) and segments(.)")
22+
## draw arrows from point to point :
23+
s <- seq(length(x)-1) # one shorter than data
24+
arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3)
25+
s <- s[-length(s)]
26+
segments(x[s], y[s], x[s+2], y[s+2], col= 'pink')
27+
})
28+
29+
test_that("segments gsplot",{
30+
x <- stats::runif(12); y <- stats::rnorm(12)
31+
i <- order(x, y); x <- x[i]; y <- y[i]
32+
gs = points(gsplot(), x, y, main = "arrows(.) and segments(.)")
33+
## draw arrows from point to point :
34+
s <- seq(length(x)-1) # one shorter than data
35+
gs = arrows(gs, x[s], y[s], x[s+1], y[s+1], col= 1:3)
36+
s <- s[-length(s)]
37+
gs = segments(gs, x[s], y[s], x[s+2], y[s+2], col= 'pink')
38+
expect_equal(names(gs$view), c("points","arrows","segments","window"))
39+
40+
})

0 commit comments

Comments
 (0)