Skip to content

Commit 4eac902

Browse files
committed
test basic adjust_numeric_calibration() usage
1 parent 0eae303 commit 4eac902

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/testthat/test-adjust-numeric-calibration.R

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
test_that("basic adjust_numeric_calibration usage works", {
2+
library(tibble)
3+
4+
set.seed(1)
5+
d_potato <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100))
6+
d_test <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100))
7+
8+
# fitting and predicting happens without raising conditions
9+
expect_no_condition(
10+
tlr <-
11+
tailor() %>%
12+
adjust_numeric_calibration(method = "linear")
13+
)
14+
15+
expect_no_condition(
16+
tlr_fit <- fit(tlr, d_potato, outcome = y, estimate = y_pred)
17+
)
18+
19+
expect_no_condition(
20+
tlr_pred <- predict(tlr_fit, d_test)
21+
)
22+
23+
# classes are as expected
24+
expect_s3_class(tlr, "tailor")
25+
expect_s3_class(tlr_fit, "tailor")
26+
expect_s3_class(tlr_pred, "tbl_df")
27+
28+
# column names are as expected
29+
expect_equal(colnames(d_test), colnames(tlr_pred))
30+
31+
# calculations match those done manually
32+
# TODO: write out the probably code manually here
33+
})
34+
35+
# TODO: test sensitivity to function arguments
36+
137
test_that("adjustment printing", {
238
expect_snapshot(tailor() %>% adjust_numeric_calibration())
339
})

0 commit comments

Comments
 (0)