Skip to content

Commit 2fe2a46

Browse files
add a failing test
1 parent d005106 commit 2fe2a46

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/testthat/test-encoding.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
context("non-ASCII characters are handled properly")
2+
3+
test_that("non-ASCII characters are handled properly", {
4+
# c.f. rlang::mut_latin1_locale()
5+
locale <- if (.Platform$OS.type == "windows") "English_United States.1252" else "en_US.ISO8859-1"
6+
7+
withr::with_locale(
8+
c(LC_CTYPE = locale),
9+
{
10+
# c.f. dplyr's tests/testthat/helper-encoding.R
11+
latin_string <- "Gl\u00fcck+1"
12+
13+
tmp <- tempfile(fileext = ".R")
14+
con <- file(tmp, encoding = "UTF-8")
15+
on.exit(close(con), add = TRUE)
16+
17+
writeLines(latin_string, con)
18+
style_file(tmp)
19+
result <- readLines(con)
20+
expect_equal(result, latin_string)
21+
}
22+
)
23+
})

0 commit comments

Comments
 (0)