From d17543d559455eddb9d8948891c9b4e3a43a702d Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 6 Feb 2024 21:52:29 +0100 Subject: [PATCH] add test --- tests/testthat/test-format_parameters.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/testthat/test-format_parameters.R b/tests/testthat/test-format_parameters.R index bae6065c2..5785f2720 100644 --- a/tests/testthat/test-format_parameters.R +++ b/tests/testthat/test-format_parameters.R @@ -381,5 +381,20 @@ withr::with_options( "e42dep [2] * c12hour" ) }) + + test_that("format_parameters, cut", { + data(mtcars) + mtcars$grp <- cut(mtcars$mpg, breaks = c(0, 15, 20, 50)) + out <- model_parameters(lm(wt ~ grp, data = mtcars)) + expect_equal( + attributes(out)$pretty_names, + c( + `(Intercept)` = "(Intercept)", `grp(15,20]` = "grp [>15-20]", + `grp(20,50]` = "grp [>20-50]" + ), + ignore_attr = TRUE + ) + expect_identical(out$Parameter, c("(Intercept)", "grp(15,20]", "grp(20,50]")) + }) } )