Skip to content

Commit e9b0fd2

Browse files
committed
stronger check
1 parent 07e8b9c commit e9b0fd2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/testthat/test-inter.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ 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_contains(colnames(result_df), c("x1", "x2", "x1:x2"))
23-
22+
expect_identical(sort(colnames(result_df)), c("x1", "x1:x2", "x2"))
23+
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_contains(colnames(result_mat), c("v1", "v2", "v1:v2"))
30-
29+
expect_identical(sort(colnames(result_mat)), c("v1", "v1:v2", "v2"))
30+
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_contains(colnames(result_no_names), c("V1", "V2", "V1:V2"))
36-
35+
expect_identical(sort(colnames(result_no_names)), c("V1", "V1:V2", "V2"))
36+
3737
# Test that it gives the same result as passing columns individually
3838
m1 = lm(mpg ~ b_inter(mtcars[, c("disp", "cyl", "hp")]), mtcars)
3939
m2 = lm(mpg ~ b_inter(disp, cyl, hp), mtcars)

0 commit comments

Comments
 (0)