tests/testthat/test-class-dstr.R

context("test-class-dstr")

ds_c <- c("dstr", "bstr", "character")
str1 <- c("ATgC")
str2 <- c("ATGz")

test_that("dstr()", {
  expect_identical(
    dstr(str1),
    structure(str1, names = "no name 1", class = ds_c)
  )

  expect_error(dstr(str2))
  expect_error(dstr(list("a")))
})

test_that("is_dstr()", {
  expect_true(is_dstr(dstr("")))
  expect_true(is_dstr(structure("", class = "dstr")))
  expect_false(is_dstr(structure("", class = "dst")))
})

test_that("as_dstr()", {
  expect_identical(
    as_dstr(str1),
    dstr(str1)
  )
})
t-arae/bstringr documentation built on March 18, 2021, 3:08 a.m.