Skip to content

Commit 9cae463

Browse files
committed
Added more test files
1 parent d22dc9d commit 9cae463

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

tests/testthat/test-pFinalSize.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test_that("pFinalSize() matches brute-force calculation", {
2+
pfs <- pFinalSize(n=1, j=4, R=1.2, k=0.33)
3+
4+
d <- dnbinom(0:3, mu=1.2, size=0.33)
5+
dnb <- d[4] * d[1]^3 +
6+
d[3] * d[2] * d[1]^2 * 2 +
7+
d[2] * d[3] * d[1]^2 +
8+
d[2]^3 * d[1]
9+
10+
expect_equal(pfs, dnb, tolerance = sqrt(.Machine$double.eps))
11+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
test_that("pFinalSizeSwitch1() matches brute-force calculation", {
2+
pfs <- pFinalSizeSwitch1(n=1, j=4, R0=1.2, k0=0.33, Rc=0.9, kc=1.1)
3+
4+
d0 <- dnbinom(0:3, mu=1.2, size=0.33)
5+
dc <- dnbinom(0:2, mu=0.9, size=1.1)
6+
dnb <- d0[4] * dc[1]^3 +
7+
d0[3] * dc[2] * dc[1]^2 * 2 +
8+
d0[2] * dc[3] * dc[1]^2 +
9+
d0[2] * dc[2]^2 * dc[1]
10+
11+
expect_equal(pfs, dnb, tolerance = sqrt(.Machine$double.eps))
12+
})

tests/testthat/test-pNextGenSize.R

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,3 @@ test_that("pNextGenSize() with multiple transmitters matches brute-force dnbinom
1010

1111
expect_equal(pngs, dnb, tolerance = sqrt(.Machine$double.eps))
1212
})
13-
14-
test_that("pFinalSize() matches brute-force calculation", {
15-
pfs <- pFinalSize(n=1, j=4, R=1.2, k=0.33)
16-
17-
d <- dnbinom(0:3, mu=1.2, size=0.33)
18-
dnb <- d[4] * d[1]^3 +
19-
d[3] * d[2] * d[1]^2 * 2 +
20-
d[2] * d[3] * d[1]^2 +
21-
d[2]^3 * d[1]
22-
23-
expect_equal(pfs, dnb, tolerance = sqrt(.Machine$double.eps))
24-
})

0 commit comments

Comments
 (0)