tests/testthat/test-usage.R

test_that("interval_vctr can survive", {
  df <- data.frame(
    x = interval(1:3, 3:5),
    y = 1:3
  )

  g <- ggplot(df, aes(xmin = x, xmax = x,
                      ymin = y - 0.4, ymax = y + 0.4)) +
    geom_rect() +
    coord_cartesian_vctr()

  ld <- layer_data(g)
  expect_is(ld$xmin, "interval_vctr")
  expect_is(ld$xmax, "interval_vctr")

  grob <- layer_grob(g)[[1]]
  expect_equal(length(grob$x), 3L)
  expect_equal(length(grob$width), 3L)
})
teunbrand/ggvctrcoords documentation built on Jan. 12, 2020, 6:25 p.m.