Skip to content

Commit

Permalink
Add simple tests for latest_issue and earliest_issue
Browse files Browse the repository at this point in the history
  • Loading branch information
capnrefsmmat committed Nov 11, 2020
1 parent 09869b3 commit b0f7e7b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions R-packages/covidcast/tests/testthat/test-utils.R
@@ -0,0 +1,33 @@
# Internal utility functions.

test_that("latest_issue gives only the latest issue", {
foo <- data.frame(
geo_value = c(rep("pa", 3), rep("tx", 3)),
issue = c(3, 2, 1, 1, 2, 3),
time_value = 1,
value = c(4, 5, 6, 7, 8, 9))

latest <- data.frame(
geo_value = c("pa", "tx"),
issue = 3,
time_value = 1,
value = c(4, 9))

expect_equal(latest_issue(foo), latest)
})

test_that("earliest_issue gives only the earliest issue", {
foo <- data.frame(
geo_value = c(rep("pa", 3), rep("tx", 3)),
issue = c(3, 2, 1, 1, 2, 3),
time_value = 1,
value = c(4, 5, 6, 7, 8, 9))

earliest <- data.frame(
geo_value = c("pa", "tx"),
issue = 3,
time_value = 1,
value = c(6, 7))

expect_equal(earliest_issue(foo), latest)
})

0 comments on commit b0f7e7b

Please sign in to comment.