Debian Codegraph @

tests/testthat/test-data-table.R

raw
1
2 test_that("skim of a simple data.table produces no warnings", {
3 skip_if_not_installed("data.table")
4 withr::local_options(list(width = 91))
5 DT_letters <- data.table::data.table(abc = letters)
6 expect_no_warning(skim(DT_letters))
7 })
8
9 test_that("skim of a simple data.table produces no warnings even with dtplyr", {
10 skip_if_not_installed("data.table")
11 skip_if_not_installed("dtplyr")
12 withr::local_options(list(width = 91))
13 DT_letters <- data.table::data.table(abc = letters)
14 expect_no_warning(skim(DT_letters))
15 })
16
17 test_that("skim of a simple data.table produces output as expected", {
18 skip_if_not_installed("data.table")
19 DT_letters <- data.table::data.table(abc = letters)
20
21 skimmed_DT_letters <- skim(DT_letters)
22 withr::local_options(list(cli.unicode = FALSE, width = 91))
23 expect_snapshot(skimmed_DT_letters)
24 })
25
26
27 test_that("skim of data.table produces output as expected", {
28 skip_if_not_installed("data.table")
29 set.seed(1L)
30
31 DT_factors <- data.table::data.table(
32 abc = letters,
33 grps = factor(sample(c("AA", "BB"), 26, TRUE)),
34 values = rnorm(26)
35 )
36
37 withr::local_options(list(cli.unicode = FALSE, width = 91))
38 expect_snapshot(skim(DT_factors))
39
40 data.table::setkeyv(DT_factors, c("abc", "grps"))
41 expect_snapshot(skim(DT_factors))
42
43 DF_factors <- as.data.frame(DT_factors)
44 expect_snapshot(skim(DF_factors))
45
46 tibble_factors <- tibble::as_tibble(DT_factors)
47 expect_snapshot(skim(tibble_factors))
48 })