Skip to content

Commit 8606301

Browse files
committed
tests 2253*: suppressWarnings, skip if no UTF-8
1 parent dcea5b5 commit 8606301

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

inst/tests/tests.Rraw

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18615,12 +18615,17 @@ test(2252.2, dt[, let(b=2L)], error = "\\[ was called on a data.table.*not data.
1861518615
rm(.datatable.aware)
1861618616

1861718617
# tests for trunc.char handling wide characters # 5096
18618-
local({
18618+
local(if (l10n_info()$`UTF-8` || {
1861918619
lc_ctype = Sys.getlocale('LC_CTYPE')
18620+
lc_wantctype = 'en_US.UTF-8'
1862018621
# Japanese multibyte characters require utf8. As of 2025, we're likely to be already running in a UTF-8 locale, but if not, try this setlocale() call as a last chance.
1862118622
# Unfortunately, there is no guaranteed, portable way of switching to UTF-8 US English.
18622-
if (!l10n_info()$`UTF-8`) Sys.setlocale('LC_CTYPE', "en_US.UTF-8")
18623-
on.exit(Sys.setlocale('LC_CTYPE', lc_ctype))
18623+
lc_newctype = suppressWarnings(Sys.setlocale('LC_CTYPE', lc_wantctype))
18624+
if (identical(lc_newctype, lc_wantctype)) {
18625+
on.exit(Sys.setlocale('LC_CTYPE', lc_ctype))
18626+
TRUE
18627+
} else FALSE
18628+
}) {
1862418629
accented_a = "\u0061\u0301"
1862518630
ja_ichi = "\u4E00"
1862618631
ja_ni = "\u4E8C"
@@ -18670,6 +18675,8 @@ local({
1867018675
paste0(c(ja_ko, ja_n, accented_a), dots, collapse=" ")))
1867118676
# test for data.table with NA, #6441
1867218677
test(2253.20, options=list(datatable.prettyprint.char = 1L), data.table(a = c("abc", NA)), output=" a\n1: a...\n2: <NA>")
18678+
} else {
18679+
cat("Tests 2253* skipped because they need a UTF-8 locale.\n")
1867318680
})
1867418681

1867518682
# allow 1-D matrix in j for consistency, #783

0 commit comments

Comments
 (0)