R Under development (unstable) (2025-01-08 r87545 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # library(testthat) > # library(footBayes) > # > # test_check("footBayes") > > > # > # > # > # context("Testing btd_foot function") > # > # test_that("btd_foot runs without errors on static data", { > # data_static <- data.frame( > # periods = rep(1, 6), > # team1 = c("AC Milan", "Roma", "Juventus", "Inter", "Roma", "AC Milan"), > # team2 = c("Juventus", "Inter", "AC Milan", "Roma", "AC Milan", "Juventus"), > # match_outcome = c(1, 2, 3, 1, 2, 1) # 1 = team1 wins, 2 = draw, 3 = team2 wins > # ) > # > # expect_silent({ > # result_static <- btd_foot( > # data = data_static, > # dynamic_rank = FALSE, > # home_effect = TRUE, > # priors = list( > # mean_psi = 0, > # std_psi = 1, > # mean_gamma = 0, > # std_gamma = 1, > # mean_home = 0, > # std_home = 2 > # ), > # rank_measure = "median", > # iter = 100, # Reduced iterations for testing speed > # chains = 1 > # ) > # }) > # > # expect_s3_class(result_static, "btdFoot") > # expect_true("fit" %in% names(result_static)) > # expect_true("rank" %in% names(result_static)) > # }) > # > # test_that("btd_foot handles missing columns gracefully", { > # data_incomplete <- data.frame( > # periods = rep(1, 3), > # team1 = c("Team A", "Team B", "Team C"), > # # Missing team2 and match_outcome > # stringsAsFactors = FALSE > # ) > # > # expect_error( > # btd_foot(data = data_incomplete), > # "Data is missing required columns: team2, match_outcome" > # ) > # }) > # > # test_that("compute_MAP returns correct mode", { > # samples <- c(1, 2, 2, 2, 3, 4, 5) > # map_estimate <- compute_MAP(samples) > # expect_equal(map_estimate, 2) > # }) > # > # test_that("check_prior validates parameters correctly", { > # expect_error(check_prior("a", "test_param"), "'test_param' must be a single numeric value.") > # expect_error(check_prior(-1, "test_param", positive = TRUE), "'test_param' must be a positive numeric value.") > # expect_silent(check_prior(1, "test_param")) > # expect_silent(check_prior(1, "test_param", positive = TRUE)) > # }) > > proc.time() user system elapsed 0.15 0.06 0.18