tests/testthat/test-debug.R

test_that("test optimization function works", {
  expect_equal(
    test_optimizer(p = 1),
    list("parameter" = 1, "value" = 1)
  )
  expect_warning(
    test_optimizer(p = 1, warning_prob = 1, warning_msg = "my warning"),
    "my warning"
  )
  expect_error(
    test_optimizer(p = 1, error_prob = 1, error_msg = "my error"),
    "my error"
  )
})

test_that("test objectiv function works", {
  expect_equal(
    test_objective(1),
    1
  )
  expect_warning(
    test_objective(1, warning_prob = 1, warning_msg = "my warning"),
    "my warning"
  )
  expect_error(
    test_objective(1, error_prob = 1, error_msg = "my error"),
    "my error"
  )
})

Try the optimizeR package in your browser

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

optimizeR documentation built on April 4, 2025, 1:56 a.m.