tests/testthat/helpers.R

expect_n_sentences <- function(lorem, n) {
  x <- format(lorem)
  paras <- unlist(strsplit(x, "\n\n"))
  sentences <- strsplit(paras, " ")

  for (i in seq_along(sentences)) {
    words <- sentences[[i]]
    n_sentences <- sum(grepl("[.!?]", words))
    n_expected <- as.integer(n[[i]])
    expect_equal(n_sentences, n_expected)
  }

  invisible(lorem)
}

Try the lorem package in your browser

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

lorem documentation built on March 31, 2023, 6:15 p.m.