tests/testthat/stringr-imported/test-unique.R

test_that("unique values returned for strings with duplicate values", {
  expect_equal(str_unique(c("a", "a", "a")), "a")
  expect_equal(str_unique(c(NA_character_, NA_character_)), NA_character_)
})

test_that("can ignore case", {
  expect_equal(str_unique(c("a", "A"), ignore_case = TRUE), "a")
})

test_that("str_unique() preserves names of first occurrences", {
  y <- c(A = "a", A2 = "a", B = "b")
  out <- str_unique(y)
  expect_equal(names(out), c("A", "B"))
})

Try the charr package in your browser

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

charr documentation built on Nov. 7, 2026, 9:06 a.m.