From c90916dec1d7ff4b0059fb984a5775653a9ac1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horva=CC=81t?= Date: Thu, 1 Feb 2024 20:16:09 +0000 Subject: [PATCH] test: voronoi() --- tests/testthat/test-voronoi.R | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/testthat/test-voronoi.R diff --git a/tests/testthat/test-voronoi.R b/tests/testthat/test-voronoi.R new file mode 100644 index 0000000000..b12e554dc4 --- /dev/null +++ b/tests/testthat/test-voronoi.R @@ -0,0 +1,11 @@ +test_that("voronoi works", { + res <- voronoi(make_ring(10), c(1, 6)) + expect_equal(res$membership, c(0, 0, 0, 1, 1, 1, 1, 1, 0, 0)) + expect_equal(res$distances, c(0, 1, 2, 2, 1, 0, 1, 2, 2, 1)) +}) + +test_that("voronoi works with weights", { + res <- voronoi(make_ring(10), c(1, 6), weights = 1:10) + expect_equal(res$membership, c(0, 0, 0, 0, 1, 1, 1, 1, 0, 0)) + expect_equal(res$distances, c(0, 1, 3, 6, 5, 0, 6, 13, 19, 10)) +})