tests/testthat/test-units.R

test_that("unit conversions are correct, vectorized, and invertible", {
  # Forward conversions
  expect_equal(gridmicrotex:::tex_pt_to_bigpt(1), 72 / 72.27, tolerance = 1e-6)
  expect_equal(gridmicrotex:::tex_pt_to_bigpt(0), 0)

  # Vectorized
  result <- gridmicrotex:::tex_pt_to_bigpt(c(72.27, 144.54))
  expect_equal(result, c(72, 144), tolerance = 1e-4)

  # Inverse round-trip
  expect_equal(
    gridmicrotex:::bigpt_to_tex_pt(gridmicrotex:::tex_pt_to_bigpt(100)),
    100, tolerance = 1e-9
  )
})

test_that("tex_pt_to_bigpt scales proportionally", {
  expect_equal(
    gridmicrotex:::tex_pt_to_bigpt(20),
    2 * gridmicrotex:::tex_pt_to_bigpt(10),
    tolerance = 1e-9
  )
})

Try the gridmicrotex package in your browser

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

gridmicrotex documentation built on May 16, 2026, 5:06 p.m.