1
+ # Test dynamics()
2
+
3
+ test_that(" Dynamics fn starts population at initial depletion * K1p" ,
4
+ {
5
+ K1p_in <- 5000
6
+ InitDepl_in <- 0.6
7
+ x <- dynamics(lh.params = list (S0 = 0.944 , S1plus = 0.99 , K1plus = K1p_in ,
8
+ AgeMat = 17 ,nages = 25 ,z = 2.39 , lambdaMax = 1.04 ),
9
+ InitDepl = InitDepl_in , ConstantCatch = NA , ConstantF = rep(0.01 , times = 100 ),
10
+ nyears = 100 )
11
+ expect_equal(K1p_in * InitDepl_in , x $ TotalPop [1 ])
12
+ })
13
+
14
+ test_that(" Dynamics fn produces a list" ,
15
+ {
16
+ xx <- dynamics(lh.params = list (S0 = 0.944 , S1plus = 0.99 , K1plus = 9000 ,
17
+ AgeMat = 17 ,nages = 25 ,z = 2.39 , lambdaMax = 1.04 ),
18
+ InitDepl = 0.6 , ConstantCatch = NA , ConstantF = rep(0.01 , times = 100 ),
19
+ nyears = 100 )
20
+ expect_type(xx , " list" )
21
+ })
22
+
23
+ test_that(" Dynamics fn produces non-NULL population and pop at age" ,
24
+ {
25
+ xx <- dynamics(lh.params = list (S0 = 0.93 , S1plus = 0.99 , K1plus = 4000 ,
26
+ AgeMat = 17 ,nages = 25 ,z = 2.39 , lambdaMax = 1.04 ),
27
+ InitDepl = 0.6 , ConstantCatch = NA , ConstantF = rep(0.01 , times = 100 ),
28
+ nyears = 100 )
29
+ expect_true(all(! is.null(xx $ TotalPop )) & all(! is.null(xx $ N )))
30
+ })
0 commit comments