Skip to content

Commit b2a7e3d

Browse files
committed
tests
1 parent 0fb669a commit b2a7e3d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/testthat/test-dplyr_methods.R

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,32 @@ test_that("rowwise()", {
377377
expect_identical(fd[[1]], sapply(df$lys, sum))
378378
})
379379

380-
test_that("group_split()", {
380+
test_that("group_split() works for one variable", {
381+
fd <- df |>
382+
group_split(groups)
383+
expect_equal(length(fd), length(unique(df$groups)))
384+
})
385+
386+
test_that("group_split() works for combination of variables", {
381387
fd <- df |>
382388
group_split(groups, ident)
383389
expect_equal(length(fd), length(unique(df$groups)) *
384390
length(unique(df$ident)))
385391
})
386392

393+
test_that("group_split() works for one logical statement", {
394+
fd_log <- df |>
395+
group_split(groups=="g1")
396+
fd_var <- df |>
397+
group_split(groups=="g1")
398+
expect_equal(lapply(fd_var, count), lapply(fd_log, count))
399+
})
400+
401+
test_that("group_split() works for two logical statements", {
402+
fd <- df |>
403+
group_split(PC_1>0 & groups=="g1")
404+
fd_counts <- lapply(fd, count)
405+
expect_equal(c(fd_counts[[1]], fd_counts[[2]], use.names = FALSE),
406+
list(75, 5))
407+
})
408+

0 commit comments

Comments
 (0)