tests/testthat/test-head.R

test_that("head(2)", {
  withr::local_envvar(DUCKPLYR_FORCE = TRUE)

  out <-
    duckdb_tibble(a = 1:5) %>%
    head(2)

  expect_identical(out$a, 1:2)
})

test_that("head(-2)", {
  withr::local_envvar(DUCKPLYR_FORCE = FALSE)

  out <-
    duckdb_tibble(a = 1:5) %>%
    head(-2)

  expect_identical(out$a, 1:3)
})

test_that("head(0)", {
  withr::local_envvar(DUCKPLYR_FORCE = TRUE)

  out <-
    duckdb_tibble(a = 1:5) %>%
    head(0)

  expect_identical(out$a, integer(0))
})

Try the duckplyr package in your browser

Any scripts or data that you put into this service are public.

duckplyr documentation built on June 8, 2025, 10:53 a.m.