Skip to content

Commit

Permalink
test: voronoi_cells()
Browse files Browse the repository at this point in the history
  • Loading branch information
szhorvat authored and aviator-bot committed Feb 20, 2024
1 parent 18c88a8 commit 8f25b90
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/testthat/test-voronoi.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("voronoi works", {
res <- voronoi_cells(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_cells(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))
})

0 comments on commit 8f25b90

Please sign in to comment.