File: test-utils.R

package info (click to toggle)
r-cran-tibble 3.0.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,492 kB
  • sloc: ansic: 315; sh: 10; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 1,070 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
test_that("needs_dim()", {
  expect_false(needs_dim(NULL))
  expect_false(needs_dim(1))
  expect_false(needs_dim(1:3))
  expect_true(needs_dim(iris))
  expect_true(needs_dim(Titanic))
})

test_that("has_nonnull_names()", {
  expect_false(has_null_names(c(a = 1)))
  expect_true(has_null_names(NULL))
  expect_true(has_null_names(1))
})

test_that("needs_list_col()", {
  expect_false(needs_list_col(1))
  expect_false(needs_list_col(matrix(1:3, nrow = 1, ncol = 3)))
  expect_true(needs_list_col(matrix(1:3, nrow = 3, ncol = 1)))
  expect_true(needs_list_col(list(1:3)))
  expect_true(needs_list_col(1:3))
  expect_true(needs_list_col(integer()))
  expect_true(needs_list_col(NULL))
  expect_true(needs_list_col(iris))
  expect_true(needs_list_col(Titanic))
})

test_that("nchar_width()", {
  expect_equal(nchar_width(""), 0)
  expect_equal(nchar_width("abc"), 3)
  expect_equal(nchar_width("\u6210"), 2)
})

test_that("is_rstudio()", {
  expect_false(withr::with_envvar(c(RSTUDIO = NA), is_rstudio()))
  expect_true(withr::with_envvar(c(RSTUDIO = 1), is_rstudio()))
})