File: test-str.R

package info (click to toggle)
r-cran-tibble 3.2.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,408 kB
  • sloc: ansic: 317; sh: 10; makefile: 5
file content (47 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
test_that("output test", {
  expect_snapshot({
    str(as_tibble(mtcars), width = 70L)

    str(as_tibble(trees), width = 70L)

    "No columns"
    str(as_tibble(trees[integer()]), width = 70L)

    "Non-syntactic names"
    df <- tibble(!!!set_names(c(5, 3), c("mean(x)", "var(x)")))
    str(df, width = 28)

    str(as_tibble(df_all), width = 70L)

    "options(tibble.width = 50)"
    withr::with_options(
      list(tibble.width = 50),
      str(as_tibble(df_all))
    )

    "options(tibble.width = 35)"
    withr::with_options(
      list(tibble.width = 35),
      str(as_tibble(df_all))
    )

    "non-tibble"
    str(5)

    Volume <- unique(trees$Volume)
    data <- unname(split(trees, trees$Volume))
    nested_trees_df <- tibble(Volume, data)
    str(nested_trees_df, width = 70L)

    data <- map(data, as_tibble)
    nested_trees_tbl <- tibble(Volume, data)
    str(nested_trees_tbl, width = 70L)
  })

  skip_if_not_installed("vctrs", "0.4.1.9000")

  expect_snapshot({
    trees2 <- as_unknown_rows(trees)
    str(trees2, width = 70L)
  })
})