Skip to content

Commit 07e8b9c

Browse files
CopilotCoryMcCartan
andcommitted
Update tests to explicitly check column names
Co-authored-by: CoryMcCartan <2958471+CoryMcCartan@users.noreply.github.com>
1 parent ffe90c7 commit 07e8b9c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/testthat/test-inter.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ test_that("b_inter() works with entire data frames", {
1919
df = data.frame(x1 = rnorm(100), x2 = rnorm(100))
2020
result_df = b_inter(df)
2121
expect_s3_class(result_df, "b_inter")
22-
expect_true(ncol(result_df) >= 3) # x1, x2, and x1:x2
22+
expect_contains(colnames(result_df), c("x1", "x2", "x1:x2"))
2323

2424
# Test with matrix with column names
2525
mat = matrix(rnorm(200), ncol = 2)
2626
colnames(mat) = c("v1", "v2")
2727
result_mat = b_inter(mat)
2828
expect_s3_class(result_mat, "b_inter")
29-
expect_true(ncol(result_mat) >= 3) # v1, v2, and v1:v2
29+
expect_contains(colnames(result_mat), c("v1", "v2", "v1:v2"))
3030

3131
# Test with matrix without column names
3232
mat_no_names = matrix(rnorm(200), ncol = 2)
3333
result_no_names = b_inter(mat_no_names)
3434
expect_s3_class(result_no_names, "b_inter")
35-
expect_true(ncol(result_no_names) >= 3) # V1, V2, and V1:V2 (default names)
35+
expect_contains(colnames(result_no_names), c("V1", "V2", "V1:V2"))
3636

3737
# Test that it gives the same result as passing columns individually
3838
m1 = lm(mpg ~ b_inter(mtcars[, c("disp", "cyl", "hp")]), mtcars)

0 commit comments

Comments
 (0)