-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
5 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,44 @@ | ||
test_that("check_pdist works correctly for valid CDF", { | ||
expect_silent(check_pdist(pnorm, D = 10)) | ||
expect_silent(check_pdist(punif, D = 1)) | ||
}) | ||
|
||
test_that("check_pdist throws error for invalid CDF", { | ||
invalid_cdf <- function(x, ...) x^2 - 1 # Not bounded between 0 and 1 | ||
expect_error( | ||
check_pdist(invalid_cdf, D = 10), | ||
"pdist is not a valid cumulative distribution function" | ||
) | ||
}) | ||
|
||
test_that("check_pdist handles infinite D correctly", { | ||
expect_silent(check_pdist(pnorm, D = Inf)) | ||
}) | ||
|
||
test_that("check_dprimary works correctly for valid PDF", { | ||
expect_silent(check_dprimary(dunif, pwindow = 1)) | ||
}) | ||
|
||
test_that("check_dprimary throws error if PDF doesn't have min and max args", { | ||
expect_error( | ||
check_dprimary(dnorm, pwindow = 1), | ||
"dprimary must take min and max as arguments" | ||
) | ||
}) | ||
|
||
test_that("check_dprimary throws error for invalid PDF", { | ||
invalid_pdf <- function(x, min, max, ...) rep(0.5, length(x)) | ||
expect_error( | ||
check_dprimary(invalid_pdf, pwindow = 1), | ||
"dprimary is not a valid probability density function" | ||
) | ||
}) | ||
|
||
test_that("check_dprimary respects tolerance", { | ||
almost_valid_pdf <- function(x, min, max, ...) dunif(x, min, max) * 1.01 | ||
expect_silent(check_dprimary(almost_valid_pdf, pwindow = 1, tolerance = 0.02)) | ||
expect_error( | ||
check_dprimary(almost_valid_pdf, pwindow = 1, tolerance = 0.005), | ||
"dprimary is not a valid probability density function" | ||
) | ||
}) |