tests/testthat/test-check_weights.R

test_that("check_weights() does not throw an error", {
  dep_var <- c(1, 3, 9, 16, 3, 7, 4, 9)
  weights <- c(2, 1, 3, 4, 4, 1, 6, 3)

  testthat::expect_error(check_weights(dep_var, weights), NA)
  testthat::expect_equal(check_weights(dep_var, weights), weights)
})


test_that("check_weights() works with weights = NULL", {
  dep_var <- c(1, 3, 9, 16, 3, 7, 4, 9)

  testthat::expect_error(check_weights(dep_var, weights = NULL), NA)
  testthat::expect_equal(check_weights(dep_var, weights = NULL), rep(1, length(dep_var)))
})

Try the rifreg package in your browser

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

rifreg documentation built on June 21, 2025, 5:08 p.m.