Skip to content

Commit 3a78922

Browse files
committed
add tests for get_rf; slight mod to example code
1 parent 29ef2c5 commit 3a78922

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

R/03_get_rf.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
#' S0 = 0.944; S1plus = 0.99; nages = 25; AgeMat = 17; z = 2.39; lambdaMax = 1.04;
1919
#' NPROut <- npr(S0 = S0, S1plus = S1plus, nages = nages, AgeMat = AgeMat, E = 0)
2020
#' N0 <- NPROut$npr # mature numbers per recruit
21-
# Get number of individuals per recruit in terms of individuals aged 1+ (\eqn{P0.w})
21+
#'
22+
# # Get number of individuals per recruit in terms of individuals aged 1+ (P0.w)
2223
#' P0 <- NPROut$P1r # 1+ nums per recruit
2324
#' Fec0 <- 1.0 / N0
2425
#' FecMax <- getfecmax(S1plus = S1plus, S0 = S0,
2526
#' AgeMat = AgeMat, lambdaMax = lambdaMax)
2627
#' A <- (FecMax - Fec0) / Fec0
28+
#'
2729
#' get_rf(E_in = 0.01, S0 = S0, S1plus = S1plus,
2830
#' nages = nages, AgeMat = AgeMat, z = z, A = A,P0 = P0,N0 = N0)
2931
#'

tests/testthat/test-get_rf.R

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Test get_rf() function
2+
3+
test_that("Confirm that get_rf() returns a single numeric value",
4+
{
5+
S0 = 0.944; S1plus = 0.99; nages = 25; AgeMat = 17; z = 2.39; lambdaMax = 1.04;
6+
NPROut <- npr(S0 = S0, S1plus = S1plus, nages = nages, AgeMat = AgeMat, E = 0)
7+
N0 <- NPROut$npr # mature numbers per recruit
8+
9+
# Get number of individuals per recruit in terms of individuals aged 1+ (P0.w)
10+
P0 <- NPROut$P1r # 1+ nums per recruit
11+
Fec0 <- 1.0 / N0
12+
FecMax <- getfecmax(S1plus = S1plus, S0 = S0,
13+
AgeMat = AgeMat, lambdaMax = lambdaMax)
14+
A <- (FecMax - Fec0) / Fec0
15+
y <- get_rf(E_in = 0.01, S0 = S0, S1plus = S1plus,
16+
nages = nages, AgeMat = AgeMat, z = z, A = A, P0 = P0, N0 = N0)
17+
expect_true(is.numeric(y))
18+
})

0 commit comments

Comments
 (0)