Skip to content

Commit a2e8ded

Browse files
committed
add test for get_diff() #58 openjournals/joss-reviews#3888
1 parent 98713aa commit a2e8ded

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

R/08_get_diff.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ get_diff <- function(logit.E, S0 = S0.w, S1plus = S1plus.w, AgeMat = AgeMat.w, n
3737
h <- 0.000001
3838

3939
NPROut <- npr(S0 = S0, S1plus = S1plus, nages = nages, AgeMat = AgeMat, E = 0)
40-
#browser()
40+
4141
N0 <- NPROut$npr
4242
P0 <- NPROut$P1r
4343

tests/testthat/test-get_diff.R

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# test get_diff function
2+
3+
test_that("get_diff returns errors when params are out of bounds",{
4+
5+
# Set params - example species phocid seal
6+
S0.w = 0.802; S1plus.w = 0.920; nages.w = 8; AgeMat.w = 6
7+
InitDepl.w = 0.9; z.w = 2.39; lambdaMax.w = 1.12
8+
9+
# Calculate A
10+
NPROut <- npr(S0 = S0.w, S1plus = S1plus.w, nages = nages.w, AgeMat = AgeMat.w, E = 0)
11+
N0 <- NPROut$npr # mature numbers per recruit
12+
Fec0 <- 1.0 / N0
13+
fmax <- getfecmax(lambdaMax = lambdaMax.w, S0 = S0.w, S1plus = S1plus.w, AgeMat = AgeMat.w)
14+
A.w <- (fmax - Fec0) / Fec0
15+
16+
expect_error(get_diff(
17+
logit.E = logit(0.01), S0 = S0.w, S1plus = 1.01, nages = nages.w, A = A.w, AgeMat = AgeMat.w,
18+
z = 2.39
19+
))
20+
})

0 commit comments

Comments
 (0)