File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 3434 Error:
3535 ! `1:3` must be a vector of length 2, not length 3.
3636
37+ # adding default coords works correctly
38+
39+ Code
40+ test <- test + coord_cartesian(xlim = c(-2, 2))
41+ Message
42+ Coordinate system already present.
43+ i Adding new coordinate system, which will replace the existing one.
44+
Original file line number Diff line number Diff line change @@ -108,3 +108,31 @@ test_that("coord expand takes a vector", {
108108
109109})
110110
111+ test_that(" adding default coords works correctly" , {
112+
113+ base <- ggplot() + coord_cartesian(default = TRUE , xlim = c(0 , 1 ))
114+
115+ # default + user = user
116+ expect_no_message(
117+ test <- base + coord_cartesian(xlim = c(- 1 , 1 ))
118+ )
119+ expect_equal(test @ coordinates $ limits $ x , c(- 1 , 1 ))
120+
121+ # user1 + user2 = user2 + message
122+ expect_snapshot(
123+ test <- test + coord_cartesian(xlim = c(- 2 , 2 ))
124+ )
125+ expect_equal(test @ coordinates $ limits $ x , c(- 2 , 2 ))
126+
127+ # user + default = user
128+ expect_no_message(
129+ test <- test + coord_cartesian(xlim = c(- 3 , 3 ), default = TRUE )
130+ )
131+ expect_equal(test @ coordinates $ limits $ x , c(- 2 , 2 ))
132+
133+ # default1 + default2 = default2 (silent)
134+ expect_no_message(
135+ test <- base + coord_cartesian(xlim = c(- 4 , 4 ), default = TRUE )
136+ )
137+ expect_equal(test @ coordinates $ limits $ x , c(- 4 , 4 ))
138+ })
You can’t perform that action at this time.
0 commit comments