Skip to content

Commit

Permalink
[R-package] fix test on non-ASCII features in non-UTF8 locales (#5526)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Oct 9, 2022
1 parent fb7f5ea commit 7fa4432
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,18 @@ test_that("lgb.train() supports non-ASCII feature names", {
data = matrix(rnorm(400L), ncol = 4L)
, label = rnorm(100L)
)
feature_names <- c("F_零", "F_一", "F_二", "F_三")
# content below is equivalent to
#
# feature_names <- c("F_零", "F_一", "F_二", "F_三")
#
# but using rawToChar() to avoid weird issues when {testthat}
# sources files and converts their encodings prior to evaluating the code
feature_names <- c(
rawToChar(as.raw(c(0x46, 0x5f, 0xe9, 0x9b, 0xb6)))
, rawToChar(as.raw(c(0x46, 0x5f, 0xe4, 0xb8, 0x80)))
, rawToChar(as.raw(c(0x46, 0x5f, 0xe4, 0xba, 0x8c)))
, rawToChar(as.raw(c(0x46, 0x5f, 0xe4, 0xb8, 0x89)))
)
bst <- lgb.train(
data = dtrain
, nrounds = 5L
Expand Down

0 comments on commit 7fa4432

Please sign in to comment.