-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple tests for latest_issue and earliest_issue
- Loading branch information
1 parent
09869b3
commit b0f7e7b
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) |