@@ -3,7 +3,6 @@ context("PPC: input validation")
33
44source(test_path(" data-for-ppc-tests.R" ))
55
6- # validating y ------------------------------------------------------------
76test_that(" validate_y works" , {
87 expect_identical(validate_y(y ), y )
98 expect_identical(validate_y(as.array(y )), y )
@@ -19,7 +18,6 @@ test_that("validate_y throws errors", {
1918 expect_error(validate_y(c(y , NA )), " NAs not allowed" )
2019})
2120
22- # validating yrep ----------------------------------------------------------
2321test_that(" validate_predictions works" , {
2422 expect_identical(validate_predictions(yrep , length(y )), yrep )
2523 expect_equal(validate_predictions(yrep2 , length(y2 )), yrep2 )
@@ -35,7 +33,6 @@ test_that("validate_predictions throws errors", {
3533 expect_error(validate_predictions(yrep , length(y2 )), " must be equal to " )
3634})
3735
38- # validating group --------------------------------------------------------
3936test_that(" validate_group works" , {
4037 expect_identical(validate_group(1 : 3 , n_obs = 3 ), as.factor(1 : 3 ))
4138 expect_identical(validate_group(as.numeric(1 : 3 ), n_obs = 3 ), as.factor(1 : 3 ))
@@ -49,8 +46,6 @@ test_that("validate_group throws errors", {
4946 " must be equal to the number of observations" )
5047})
5148
52-
53- # validating x --------------------------------------------------------
5449test_that(" validate_x works" , {
5550 x <- rnorm(3 )
5651 expect_identical(validate_x(x , y = 1 : 3 ), x )
@@ -65,3 +60,11 @@ test_that("validate_x throws errors", {
6560 expect_error(validate_x(c(1 ,2 ,NA ), y = 1 : 3 ), " NAs not allowed" )
6661 expect_error(validate_x(1 : 4 , y = 1 : 3 ), " must be equal to" )
6762})
63+
64+ test_that(" validate_pit works" , {
65+ expect_error(validate_pit(" pit" ), " is.numeric" )
66+ expect_error(validate_pit(cbind(1 , 2 )), " vector" )
67+ expect_error(validate_pit(- 1 ), " between 0 and 1" )
68+ expect_error(validate_pit(NA ), " NAs not allowed" )
69+ expect_identical(validate_pit(c(name = 0.5 )), 0.5 )
70+ })
0 commit comments