tests/testthat/test-codeunits.R

test_that("Code units are correctly calculated", {
    skip_on_os("solaris")
    expect_equal(ncodeunit("a"), 1)
    expect_equal(ncodeunit("𐐀"), 2)
    expect_equal(ncodeunit("佢"), 1)
    expect_equal(ncodeunit("𠍲"), 2)
    expect_equal(ncodeunit(c("佢", "𠍲")), c(1, 2))
    expect_equal(code_point_from_unit("a𐐀c", c(0:5, Inf)), c(0, 1, NA, 2, 3, 3, 3))
    expect_equal(code_point_to_unit("a𐐀c", c(0:4, Inf)), c(0, 1, 3, 4, 4, 4))
})

Try the languageserver package in your browser

Any scripts or data that you put into this service are public.

languageserver documentation built on Aug. 18, 2023, 9:06 a.m.