Skip to content

Commit

Permalink
✅ Add test case for creation of spatiotemporal event
Browse files Browse the repository at this point in the history
  • Loading branch information
NONONOexe committed Sep 16, 2024
1 parent 9338d33 commit 8c17d41
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-create-spatiotemporal-event.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
test_that("`create_spatiotemporal_event` works with valid input", {
spatiotemporal_events <- create_spatiotemporal_event(sample_accidents)

expect_s3_class(spatiotemporal_events, "spatiotemporal_event")
expect_equal(attr(spatiotemporal_events, "time_column"), "time")
expect_equal(attr(spatiotemporal_events, "time_format"), "%H")
})

test_that("`print.spatiotemporal_event` prints the correct information", {
spatiotemporal_events <- create_spatiotemporal_event(sample_accidents)
output <- capture.output(print(spatiotemporal_events))

expect_equal(output[1],
"Spatiotemporal event collection with 10 events and 3 fields")
expect_equal(output[2], "Geometry type: POINT")
expect_equal(output[3], "Time column: time")
expect_equal(output[4], "Time format: %H")
expect_equal(output[5], "Data:")
expect_equal(output[7], "1 ac_0001 18 Sunny Minor POINT (1 1)")
expect_equal(output[11], "5 ac_0005 7 Rainy Minor POINT (5.9 1.1)")
expect_equal(output[12], "... 5 more events")
})

0 comments on commit 8c17d41

Please sign in to comment.