tests/testthat/test-locale.R
raw| 1 | test_that("with_locale works and resets locales", { |
| 2 | current <- Sys.getlocale("LC_CTYPE") |
| 3 | new <- "C" |
| 4 | with_locale( |
| 5 | c(LC_CTYPE = new), |
| 6 | { |
| 7 | expect_equal(new, Sys.getlocale("LC_CTYPE")) |
| 8 | } |
| 9 | ) |
| 10 | expect_equal(current, Sys.getlocale("LC_CTYPE")) |
| 11 | }) |
| 12 | |
| 13 | test_that("with_locale fails with LC_ALL", { |
| 14 | expect_error(with_locale(c(LC_ALL = "C"), NULL), "LC_ALL") |
| 15 | }) |