Skip to content

Commit 11d9ecb

Browse files
committed
Apply suggestion to improve geom_curve() test
1 parent a3597ce commit 11d9ecb

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

tests/testthat/test-geom-curve.R

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,37 @@ test_that("geom_curve shape works", {
1414

1515
df <- data.frame(x = c(1, 3), xend = c(2, 4), y = c(0, 1), yend = c(2, 1.5))
1616

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)
17+
p <- ggplot(df) +
18+
geom_curve(
19+
aes(x, y, xend = xend, yend = yend, color = "square"),
20+
curvature = 1,
21+
shape = 0,
22+
ncp = 1
23+
) +
24+
geom_curve(
25+
# This layer will use `square = FALSE` in curveGrob because angle != 90
26+
aes(x, y, xend = xend, yend = yend, color = "square tilted"),
27+
angle = 60,
28+
curvature = 1,
29+
shape = 0,
30+
ncp = 1
31+
) +
32+
geom_curve(
33+
aes(x, y, xend = xend, yend = yend, color = "spline cubic"),
34+
curvature = -.5,
35+
angle = 40,
36+
shape = 1,
37+
ncp = 1
38+
) +
39+
geom_curve(
40+
aes(x, y, xend = xend, yend = yend, color = "spline interpolating"),
41+
curvature = -.5,
42+
angle = 40,
43+
shape = -1,
44+
ncp = 1
45+
) +
46+
NULL
47+
48+
expect_doppelganger("multishape geom_curve", p)
3449

3550
})

0 commit comments

Comments
 (0)