tests/testthat/test_cites.R

context("Citation formatting")

test_that("Postnotes detected", {
  expect_error(check_cite_pagerefs("./check-cite-pagerefs/cite-no-postnote.tex"), regexp = "postnote")
  expect_error(check_cite_pagerefs("./check-cite-pagerefs/cite-p-in-postnote.tex"), regexp = "p in postnote")
  expect_error(check_cite_pagerefs("./check-cite-pagerefs/cite-pp-in-postnote.tex"), regexp = "p in postnote")
})


test_that("Singular text/footcite with two keys should error", {
  expect_error(check_cite_pagerefs("./check-cite-pagerefs/29-bad-singular-cite.tex"),
               regexp = "Use of singular form")
})


test_that("Page reference ok if in correct format", {
  expect_null(check_cite_pagerefs("./check-cite-pagerefs/ok-page-ref-roman.tex"))
  expect_null(check_cite_pagerefs("./check-cite-pagerefs/cite-p-in-text-postnote.tex"))
  expect_error(check_cite_pagerefs("./check-cite-pagerefs/bad-cite-p-in-text-postnote-2.tex"), regexp = "Page reference not in correct format")
  expect_error(check_cite_pagerefs("./check-cite-pagerefs/bad-cite-p-in-text-postnote.tex"), regexp = "Page reference not in correct format")
})

test_that("Cite pagerefs false positives", {
  expect_null(check_cite_pagerefs("./check-cite-pagerefs/ok-page-ref-4pm.tex"))
})
HughParsonage/grattanReporter documentation built on May 7, 2019, 5:02 a.m.