Skip to content

Commit

Permalink
test expected dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
robitalec committed Nov 1, 2024
1 parent 13cde68 commit 36b2c80
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/testthat/test-distance-to-leader.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,34 @@ test_that('returns a data.table', {
expect_s3_class(distance_to_leader(DT, coords = coords, group = group),
'data.table')
})


expect_DT <- data.table(
ID = c('A', 'B'),
X = c(0, 10),
Y = c(0, 0),
group_direction = rep(as_units(0, 'rad'), 2),
group = c(1, 1)
)
centroid_group(expect_DT, coords = coords)
leader_direction_group(expect_DT, coords = coords,
return_rank = TRUE, group = group)
distance_to_leader(expect_DT, coords = c('X', 'Y'))

test_that('expected results for simple case', {
expect_lte(
expect_DT[, max(distance_leader)],
10
)

expect_gte(
expect_DT[, min(distance_leader)],
0
)
expect_equal(
expect_DT[distance_leader == min(distance_leader), ID],
'B'
)
})


0 comments on commit 36b2c80

Please sign in to comment.