Skip to content

Commit c8a95f3

Browse files
author
Jordan S Read
committed
test and code for #263
1 parent 7461b4e commit c8a95f3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

R/calc_views.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ unname_c <- function(list){
187187
do.call(c, unname(list))
188188
}
189189
views_with_side <- function(views, side){
190+
if(length(side) > 1)
191+
stop('side can only be length of 1')
190192
with.side = lapply(views, function(x) any(x[['window']][['side']] %in% side))
191193
view.match = unname(unlist(with.side[names(with.side) == 'view']))
192194
if (is.null(view.match) || !any(view.match))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
context("views_with_side")
2+
test_that("views with side retains order", {
3+
4+
usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>%
5+
points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat') %>%
6+
points(4,3,side=1,2)
7+
expect_error(gsplot:::views_with_side(usrDef,c(1,3)))
8+
expect_equal(gsplot:::views_with_side(usrDef,3), 1)
9+
expect_equal(gsplot:::views_with_side(usrDef,1), 2)
10+
11+
})

0 commit comments

Comments
 (0)