diff --git a/tests/testthat/_snaps/utf8.md b/tests/testthat/_snaps/utf8.md new file mode 100644 index 00000000..eb2db9f6 --- /dev/null +++ b/tests/testthat/_snaps/utf8.md @@ -0,0 +1,14 @@ +# UTF-8 encoding, string input + + Code + print(out_utf8[i_out]) + Output + [1] "#> [1] \"À\" \"Ë\" \"Ð\"" + +--- + + Code + print(charToRaw(out_utf8[i_out])) + Output + [1] 23 3e 20 5b 31 5d 20 22 c3 80 22 20 22 c3 8b 22 20 22 c3 90 22 + diff --git a/tests/testthat/test-utf8.R b/tests/testthat/test-utf8.R index 3f99f01b..605e4f05 100644 --- a/tests/testthat/test-utf8.R +++ b/tests/testthat/test-utf8.R @@ -8,17 +8,20 @@ test_that("UTF-8 encoding, string input", { ) out_utf8 <- reprex(input = in_utf8) - expect_true(all(Encoding(out_utf8) %in% c("unknown", "UTF-8"))) - i_in <- grep("^x <-", in_utf8) i_out <- grep("^x <-", out_utf8) expect_identical(charToRaw(in_utf8[i_in]), charToRaw(out_utf8[i_out])) i_out <- grep("^#> \\[1\\]", out_utf8) + expect_equal(Encoding(out_utf8)[i_out], "UTF-8") expect_match(out_utf8[i_out], "[\u00C0]") expect_match(out_utf8[i_out], "[\u00CB]") expect_match(out_utf8[i_out], "[\u00D0]") + expect_snapshot(print(out_utf8[i_out])) + expect_snapshot(print(charToRaw(out_utf8[i_out]))) + #expect_snapshot(print(Sys.getlocale())) + in_latin1 <- iconv(in_utf8, from = "UTF-8", to = "latin1") out_latin1 <- reprex(input = in_latin1)