tests/testthat/test-parse-heap-gb.R

# ──────────────────────────────────────────────────────────────────────────────
# parse_heap_gb.R
# ──────────────────────────────────────────────────────────────────────────────

test_that("parse_heap_gb converts valid strings", {
  expect_equal(parse_heap_gb("2g"), 2)
  expect_equal(parse_heap_gb("2gb"), 2)
  expect_equal(parse_heap_gb("2048m"), 2)
  expect_equal(parse_heap_gb("2048mb"), 2)
  # Test with uppercase letters
  expect_equal(parse_heap_gb("2G"), 2)
  expect_equal(parse_heap_gb("2GB"), 2)
  expect_equal(parse_heap_gb("2048M"), 2)
  expect_equal(parse_heap_gb("2048MB"), 2)
})

test_that("parse_heap_gb rejects invalid strings", {
  expect_error(parse_heap_gb("2"), "not recognised")
  expect_error(parse_heap_gb("two"), "not recognised")
  expect_error(parse_heap_gb("2gbb"), "not recognised")
})

Try the causalDisco package in your browser

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

causalDisco documentation built on April 13, 2026, 5:06 p.m.