Skip to content

Commit 4ba4226

Browse files
committed
add another test for get_f() #58
1 parent f50b4e2 commit 4ba4226

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/testthat/test-get_f.R

+23-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test_that("get_f() returns a single numeric value",
55
S1plus.w = 0.944
66
nages.w = 25
77
AgeMat.w = 18
8-
InitDepl.w = 0.9
8+
InitDepl.w = 0.5
99
z.w = 2.39
1010
lambdaMax.w = 1.04
1111

@@ -19,6 +19,27 @@ test_that("get_f() returns a single numeric value",
1919
S0.w = S0.w, S1plus.w = S1plus.w, nages.w = nages.w, AgeMat.w = AgeMat.w,
2020
InitDepl.w = InitDepl.w, z.w = z.w, lambdaMax.w = lambdaMax.w,
2121
N0.w = N0, P0.w = P0, Check = FALSE)
22-
print(x)
2322
expect_true(is.numeric(x))
2423
})
24+
25+
test_that("uniroot() fails if initial depletion = 1",
26+
{
27+
S0.w = 0.5
28+
S1plus.w = 0.944
29+
nages.w = 25
30+
AgeMat.w = 18
31+
InitDepl.w = 1
32+
z.w = 2.39
33+
lambdaMax.w = 1.04
34+
35+
NPROut <- npr(S0 = S0.w, S1plus = S1plus.w,
36+
nages = nages.w, AgeMat = AgeMat.w, E = 0)
37+
N0 <- NPROut$npr # mature numbers per recruit
38+
P0 <- NPROut$P1r # 1+ nums per recruit
39+
40+
# Get bycatch mortality rate for the initial depletion defined above
41+
expect_error(get_f(f.start = 0.1,
42+
S0.w = S0.w, S1plus.w = S1plus.w, nages.w = nages.w, AgeMat.w = AgeMat.w,
43+
InitDepl.w = InitDepl.w, z.w = z.w, lambdaMax.w = lambdaMax.w,
44+
N0.w = N0, P0.w = P0, Check = FALSE))
45+
})

0 commit comments

Comments
 (0)