# Generated by 04-dplyr-tests.R, do not edit by hand # Workaround for lazytest test_that("Dummy", { expect_true(TRUE) }) skip_if(Sys.getenv("DUCKPLYR_SKIP_DPLYR_TESTS") == "TRUE") # group_data -------------------------------------------------------------- test_that("group_data() returns a data frame", { df <- data.frame(x = 1:3) gd <- group_data(df) expect_s3_class(gd, "data.frame", exact = TRUE) expect_equal(gd$.rows, list_of(1:3)) }) test_that("group_data() returns a tibble", { df <- tibble(x = 1:3) gd <- group_data(df) expect_s3_class(gd, "tbl_df") expect_equal(gd, tibble(".rows" := list_of(1:3))) }) test_that("group_data() returns a tibble", { df <- tibble(x = c(1, 1, 2)) gf <- duckplyr_group_by(df, x) gd <- group_data(gf) expect_s3_class(gd, "tbl_df") expect_equal( gd, tibble(x = c(1, 2), ".rows" := list_of(1:2, 3L)), ignore_attr = TRUE ) }) test_that("group_data( duckplyr_group_by(x) expect_equal(duckplyr_n_groups(df), 3L) expect_equal(duckplyr_group_size(df), rep(10, 3)) }) # n_groups ---------------------------------------------------------------- test_that("n_groups respects zero-length groups (#341)", { df <- tibble(x = factor(1:3, levels = 1:4)) |> duckplyr_group_by(x, .drop = FALSE) expect_equal(duckplyr_n_groups(df), 4) })