tests/testthat/test-message2.R

#message2_001
test_that("message2 prints messages without errors", {
  # Should not throw errors
  expect_error(message2("Test message"), NA)
  expect_error(message2("Test", "message", "with", "multiple", "parts"), NA)
})


#message2_002
test_that("message2 handles different colors", {
  # Test various color options
  expect_error(message2("Red message", col = "red"), NA)
  expect_error(message2("Blue message", col = "blue"), NA)
  expect_error(message2("Cyan message", col = "cyan"), NA)
  expect_error(message2("Green message", col = "green"), NA)
  expect_error(message2("Custom color", col = "dodgerblue"), NA)
})

#message2_003
test_that("message2 handles font parameter", {
  # Font 1 (plain)
  expect_error(message2("Plain text", font = 1), NA)
  
  # Font 2 (bold)
  expect_error(message2("Bold text", font = 2), NA)
})

#message2_004
test_that("message2 handles stop parameter", {
  # When stop=TRUE, should stop execution
  expect_error(message2("This stops", stop = TRUE), class = "simpleError")
  
  # When stop=FALSE, should not stop
  expect_error(message2("This doesn't stop", stop = FALSE), NA)
})


#message2_005
test_that("message2 handles multiple message parts", {
  # Multiple arguments should be combined
  expect_error(message2("Part", "1", "and", "Part", "2"), NA)
  
  # With numeric values
  expect_error(message2("Value:", 42), NA)
  
  # With mixed types
  expect_error(message2("Count:", 5, "items"), NA)
})

#message2_006
test_that("message2 returns invisibly", {
  result <- message2("Test")
  expect_null(result)
})

Try the statuser package in your browser

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

statuser documentation built on April 25, 2026, 5:06 p.m.