tests/testthat/test-strip_query.R

context("strip_query")

test_that("strip_query strips limit and offset", {
  expect_equal(strip_query("limit 1"), "")
  expect_equal(strip_query("limit    1 "), " ")
  expect_equal(strip_query("a limit 1"), "a ")
  expect_equal(strip_query("offset    1 "), " ")
  expect_equal(strip_query("a offset 1"), "a ")
  expect_equal(strip_query("limit 1 offset 1"), " ")
  expect_equal(strip_query("a limit 1 offset 1"), "a  ")
  expect_equal(strip_query("offset 1 limit 1"), " ")
  expect_equal(strip_query("a offset 1 limit 1"), "a  ")
  expect_equal(strip_query("a offset 1 limit 1 order by b"), "a   order by b")
})

Try the kntnr package in your browser

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

kntnr documentation built on April 14, 2020, 5:36 p.m.