@@ -13,15 +13,21 @@ context("legend")
1313
1414test_that(" gsplot legend works" , {
1515
16- gs <- gsplot()
16+ gs <- gsplot() %> %
17+ points(x = 1 , y = 2 , legend.name = " Points 1" , pch = 1 , col = " blue" ) %> %
18+ points(x = 3 , y = 4 , legend.name = " Points 2" , pch = 5 , col = " red" ) %> %
19+ error_bar(3 ,4 , y.high = 0.2 , y.low = 0.3 , legend.name = " Errors" , text.font = 2 ) %> %
20+ rect(2 ,3 ,2.5 ,4 , col = " blue" , border = " orange" , lwd = 3 , density = 15 , legend.name = " rectangle" ) %> %
21+ legend(location = " bottomright" , bg = " lightgrey" )
1722
1823 expect_is(gs , " gsplot" )
19-
20- gs <- points(gs , x = 1 , y = 2 , side = c(3 ,2 ), legend.name = " Points 1" , pch = 1 , col = " blue" ) %> %
21- points(x = 3 , y = 4 , side = c(1 ,4 ), legend.name = " Points 2" , pch = 5 , col = " red" ) %> %
22- legend(location = " bottomright" )
23-
24+ expect_equal(gs $ legend $ gs.config $ bg , " lightgrey" )
2425 expect_equal(gs $ legend $ gs.config $ location , " bottomright" )
26+ expect_equal(length(which(names(gs $ legend )== " legend.args" )), 3 )
27+ expect_equal(gs $ legend [[1 ]]$ fill , quote(par(" bg" )))
28+ expect_equal(gs $ legend [[4 ]]$ lwd , NA )
29+ expect_equal(gs $ legend [[2 ]]$ density , NA )
30+ expect_equal(gs $ legend [[3 ]]$ text.font , 2 )
2531
2632})
2733
0 commit comments