generated from epiverse-trace/packagetemplate
-
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
1 parent
f348ea0
commit ade7699
Showing
1 changed file
with
32 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,32 @@ | ||
test_that(".fit works as expected" ,{ | ||
func <- function(x) { | ||
(x - 3)^2 + 5 | ||
} | ||
expect_equal(.fit(func = func, fit_method = "optim", upper = 5), 3) | ||
}) | ||
|
||
test_that(".fit fails as expected", { | ||
expect_error( | ||
.fit(func = "function", fit_method = "optim"), | ||
regexp = "func must be a function" | ||
) | ||
func <- function(x) { | ||
(x - 3)^2 + 5 | ||
} | ||
expect_error( | ||
.fit(func = func, fit_method = "other"), | ||
regexp = "(arg)*(should be one of)*(optim)*(grid)" | ||
) | ||
expect_error( | ||
.fit(func = func, fit_method = "optim", a = 1, a = 2), | ||
regexp = "(Arguments)*(must have unique names)" | ||
) | ||
expect_error( | ||
.fit(func = func, fit_method = "optim", mthod = "L-BFGS-B"), | ||
regexp = "Arguments supplied in `...` not valid" | ||
) | ||
expect_error( | ||
.fit(func = func, fit_method = "grid", method = "L-BFGS-B"), | ||
regexp = "Arguments supplied in `...` not valid" | ||
) | ||
}) |