tests/testthat/test-DecisionNode.R

test_that("missing, non-character or empty labels are rejected", {
  expect_error(DecisionNode$new(), class = "missing_label")
  expect_error(DecisionNode$new(42L), class = "non-string_label")
  expect_error(DecisionNode$new(""), class = "empty_label")
  expect_silent(DecisionNode$new("my node"))
})

test_that("syntactically invalid labels are corrected", {
  d <- DecisionNode$new("my_label")
  expect_identical(d$label(), "my_label")
  d <- DecisionNode$new("my label")
  expect_identical(d$label(), "my.label")
  d <- DecisionNode$new("2_label")
  expect_identical(d$label(), "X2_label")
  d <- DecisionNode$new("2.label")
  expect_identical(d$label(), "X2.label")
})

Try the rdecision package in your browser

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

rdecision documentation built on June 22, 2024, 10:02 a.m.