-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtest-inputs.R
More file actions
78 lines (69 loc) · 1.57 KB
/
test-inputs.R
File metadata and controls
78 lines (69 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
library(testthat)
library(abind)
test_that("Check different input formats", {
basic_data <- cbind(0:2, 1:3, 2:4)
rownames(basic_data) <- LETTERS[1:3]
expect_silent(
abind(basic_data,
basic_data + 1,
along = 3
) |>
forestplot(labeltext = 1:3)
)
expect_silent(
abind(basic_data,
basic_data + 1,
along = 3
) |>
forestplot()
)
expect_silent(forestplot(
cbind(
0:2,
1:3,
2:4
),
labeltext = 1:3
))
expect_silent(forestplot(
cbind(
c(NA, 1:2),
c(NA, 2:3),
c(NA, 3:4)
),
labeltext = 1:3
))
expect_error(forestplot(
cbind(
0:2,
3:1,
2:4
),
labeltext = 1:3
))
expect_error(
abind(basic_data,
cbind(0:2, 3:1, 2:4),
along = 3
) |>
forestplot()
)
# new validation cases ------------------------------------------------------
# mean outside CI (deliberately outside bounds)
df <- data.frame(coef = 1, low = -1, high = 0.5)
expect_error(
forestplot(df, labeltext = 1, mean = coef, lower = low, upper = high),
"Estimate outside confidence interval"
)
# lower > upper (negative values included)
df2 <- data.frame(coef = -2, low = -1, high = -3)
expect_error(
forestplot(df2, labeltext = 1, mean = coef, lower = low, upper = high),
"lower bound exceeds upper bound"
)
# valid negative scenario should be silent
df3 <- data.frame(coef = c(-2, -4), low = c(-2.5, -5), high = c(-1.5, -3))
expect_silent(
forestplot(df3, labeltext = 1:2, mean = coef, lower = low, upper = high)
)
})