inst/tinytest/test_convert_umlauts_to_ascii.R

if (interactive()) {
  pkgload::load_all()
  library("tinytest")
}
if (fritools2::is_version_sufficient(
  fritools2::get_package_version("base"),
  "4.0.0"
)) {
  if (interactive()) pkgload::load_all(".")

  string <- c(
    "\u00e4", "\u00c4", "\u00f6", "\u00d6", "\u00fc", "\u00dc",
    "\u00df"
  )
  expectation <- c("ae", "Ae", "oe", "Oe", "ue", "Ue", "sz")
  result <- convert_umlauts_to_ascii(string)
  expect_identical(result, expectation)
  df <- data.frame(
    v1 = c(string, "foobar"),
    v2 = c("foobar", string), v3 = 3:4
  )
  names(df)[3] <- "y\u00dfy"
  result <- convert_umlauts_to_ascii(df)
  expectation <-
    structure(list(
      v1 = c(
        "ae", "Ae", "oe", "Oe", "ue", "Ue", "sz",
        "foobar"
      ),
      v2 = c(
        "foobar", "ae", "Ae", "oe", "Oe", "ue", "Ue",
        "sz"
      ),
      yszy = c(3L, 4L, 3L, 4L, 3L, 4L, 3L, 4L)
    ),
    class = "data.frame", row.names = c(NA, -8L)
    )
  expect_identical(result, expectation)
}
if (interactive()) {

}

Try the fritools2 package in your browser

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

fritools2 documentation built on July 9, 2023, 7:07 p.m.