@@ -422,3 +422,54 @@ test_that("ppc_pit_ecdf, ppc_pit_ecdf_grouped renders correctly", {
422422 vdiffr :: expect_doppelganger(" ppc_pit_ecdf (diff)" , p_diff )
423423 vdiffr :: expect_doppelganger(" ppc_pit_ecdf_grouped (diff)" , g_diff )
424424})
425+
426+
427+ # ppc_data / ppd_data tests -----------------------------------------------
428+
429+ test_that(" ppc_data returns correct structure" , {
430+ d <- ppc_data(y , yrep )
431+ expect_s3_class(d , " data.frame" )
432+ expect_true(all(c(" y_id" , " rep_id" , " rep_label" , " is_y" , " value" ) %in% names(d )))
433+ })
434+
435+ test_that(" ppc_data includes y and yrep rows" , {
436+ d <- ppc_data(y , yrep )
437+ y_rows <- d [d $ is_y , ]
438+ yrep_rows <- d [! d $ is_y , ]
439+ expect_equal(nrow(y_rows ), length(y ))
440+ expect_equal(nrow(yrep_rows ), length(y ) * nrow(yrep ))
441+ expect_equal(y_rows $ value , y )
442+ })
443+
444+ test_that(" ppc_data with group adds group column" , {
445+ d <- ppc_data(y , yrep , group = group )
446+ expect_true(" group" %in% names(d ))
447+ expect_equal(nlevels(factor (d $ group )), nlevels(group ))
448+ })
449+
450+ test_that(" ppc_data works with single replicate" , {
451+ d <- ppc_data(y , yrep [1 , , drop = FALSE ])
452+ yrep_rows <- d [! d $ is_y , ]
453+ expect_equal(nrow(yrep_rows ), length(y ))
454+ })
455+
456+ test_that(" ppd_data returns correct structure" , {
457+ d <- ppd_data(yrep )
458+ expect_s3_class(d , " data.frame" )
459+ expect_true(all(c(" y_id" , " rep_id" , " rep_label" , " value" ) %in% names(d )))
460+ })
461+
462+ test_that(" ppd_data returns correct number of rows" , {
463+ d <- ppd_data(yrep )
464+ expect_equal(nrow(d ), nrow(yrep ) * ncol(yrep ))
465+ })
466+
467+ test_that(" ppd_data with group adds group column" , {
468+ d <- ppd_data(yrep , group = group )
469+ expect_true(" group" %in% names(d ))
470+ })
471+
472+ test_that(" ppd_data works with single replicate" , {
473+ d <- ppd_data(yrep [1 , , drop = FALSE ])
474+ expect_equal(nrow(d ), ncol(yrep ))
475+ })
0 commit comments