Skip to content

Commit e01c4b7

Browse files
committed
add tests for extract_df()
1 parent 8d90bc5 commit e01c4b7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/testthat/test-extract_df.R

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
test_that("extract_df() returns a dataframe w the correct number of sims",
2+
{
3+
nyrs_test <- 100
4+
xx <- projections(
5+
NOut = 3, ConstantRateBycatch = list(Rate = 0.01, CV = 0.3),
6+
InitDepl = 0.8,
7+
lh.params = list(
8+
S0 = 0.944, S1plus = 0.99,
9+
K1plus = 9000, AgeMat = 18, nages = 20, z = 2.39, lambdaMax = 1.02
10+
),
11+
nyears = nyrs_test, obs_CV = 0
12+
)
13+
yy <- extract_df(xx)
14+
expect_true(colnames(yy)[nyrs_test+1]=="sim")
15+
})
16+
17+
test_that("extract_df() has all needed columns from the projections",
18+
{
19+
20+
xx <- projections(
21+
NOut = 3, ConstantRateBycatch = list(Rate = 0.01, CV = 0.3),
22+
InitDepl = 0.8,
23+
lh.params = list(
24+
S0 = 0.944, S1plus = 0.99,
25+
K1plus = 9000, AgeMat = 18, nages = 20, z = 2.39, lambdaMax = 1.02
26+
),
27+
nyears = 50, obs_CV = 0
28+
)
29+
yy <- extract_df(xx)
30+
expect_true("sim" %in% colnames(yy) &
31+
"Bycatch_Catch" %in% colnames(yy) &
32+
"Bycatch_CV" %in% colnames(yy) &
33+
"Bycatch_Rate" %in% colnames(yy) &
34+
"Bycatch_Rate_CV" %in% colnames(yy) &
35+
"InitDepl" %in% colnames(yy))
36+
})

0 commit comments

Comments
 (0)