File: testthat.R

package info (click to toggle)
r-cran-cli 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,780 kB
  • sloc: sh: 13; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 693 bytes parent folder | download | duplicates (3)
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
library(testthat)
library(cli)

## Run the tests in fancy mode and non-fancy mode as well
## Also, run them in latin1 encoding as well, this is for Unix,
## because Windows encoding names are different.

withr::with_options(
  list(cli.unicode = FALSE),
  test_check("cli")
)

withr::with_options(
  list(cli.unicode = TRUE),
  test_check("cli")
)

has_locale <- function(l) {
  has <- TRUE
  tryCatch(
    withr::with_locale(c(LC_CTYPE = l), "foobar"),
    warning = function(w) has <<- FALSE,
    error = function(e) has <<- FALSE
  )
  has
}

if (l10n_info()$`UTF-8` && has_locale("en_US.ISO8859-1")) {
  withr::with_locale(
    c(LC_CTYPE = "en_US.ISO8859-1"),
    test_check("cli")
  )
}