tests/testthat/test_next_prime.R

context("Next and previous primes")

test_that("Search for next prime works", {
  expect_equal(next_prime(-1:7), c(2L, 2L, 2L, 3L, 5L, 5L, 7L, 7L, 11L))
})

test_that("Search for previous also works", {
  expect_equal(prev_prime(-1:7), c(NA, NA, NA, NA, 2L, 3L, 3L, 5L, 5L))
})
Ironholds/primes documentation built on Feb. 1, 2024, 1:26 a.m.