test_that("border_weights is symmetric, hollow, and sums to 1", { coords <- expand.grid(x = 0:2, y = 0:2) W <- border_weights(coords) expect_s3_class(W, "border_weights") expect_equal(diag(W), rep(0, nrow(W))) # hollow expect_equal(W, t(W)) # symmetric expect_equal(sum(W), 1) # standardized }) test_that("border_weights matches inverse-distance definition", { coords <- data.frame(x = c(0, 1), y = c(0, 0)) W <- border_weights(coords, standardize = FALSE) expect_equal(W[1, 2], 1) # 1 / dist(=1) expect_equal(diag(W), c(0, 0)) }) test_that("border_weights errors on degenerate coords", { expect_error(border_weights(data.frame(x = c(0, 0), y = c(0, 0))), "distance") })