tests/testthat/test-horns.R

test_that("`horns()` works correctly in the 1-5 case", {
  c(300, 0, 0, 0, 0)    |> horns(1, 5) |> expect_equal(0)
  c(150, 0, 0, 0, 150)  |> horns(1, 5) |> expect_equal(1)
  c(60, 60, 60, 60, 60) |> horns(1, 5) |> expect_equal(0.5)
})


test_that("`horns()` works correctly in the 1-2 case", {
  c(10, 10) |> horns(1, 2) |> expect_equal(1)
  c(10, 0)  |> horns(1, 2) |> expect_equal(0)
  c(10, 5)  |> horns(1, 2) |> expect_equal(0.8888889)
})

Try the unsum package in your browser

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

unsum documentation built on June 20, 2025, 1:08 a.m.