@@ -9,3 +9,27 @@ test_that("geom_curve flipping works", {
99 expect_doppelganger(" flipped geom_curve" , p + scale_y_reverse())
1010
1111})
12+
13+ test_that(" geom_curve shape works" , {
14+
15+ df <- data.frame (x = c(1 , 3 ), xend = c(2 , 4 ), y = c(0 , 1 ), yend = c(2 , 1.5 ))
16+
17+ p_0 <- ggplot(df , aes(x , y , xend = xend , yend = yend )) +
18+ geom_curve(arrow = arrow(), shape = 0 , ncp = 1 , curvature = 1 )
19+
20+ # This will use `square = FALSE` in curveGrob because angle != 90
21+ p_0_not_square <- ggplot(df , aes(x , y , xend = xend , yend = yend )) +
22+ geom_curve(arrow = arrow(), shape = 0 , ncp = 1 , curvature = 1 , angle = 60 )
23+
24+ p_1 <- ggplot(df , aes(x , y , xend = xend , yend = yend )) +
25+ geom_curve(arrow = arrow(), shape = 1 )
26+
27+ p_m1 <- ggplot(df , aes(x , y , xend = xend , yend = yend )) +
28+ geom_curve(arrow = arrow(), shape = - 1 , angle = 40 )
29+
30+ expect_doppelganger(" shape=0 geom_curve" , p_0 )
31+ expect_doppelganger(" shape=0 geom_curve" , p_0_not_square )
32+ expect_doppelganger(" shape=1 geom_curve" , p_1 )
33+ expect_doppelganger(" shape=-1 geom_curve" , p_m1 )
34+
35+ })
0 commit comments