Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 10, 2024
1 parent 30f6ba5 commit b45a517
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/row_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ row_count <- function(data,

data <- .coerce_to_dataframe(data[select])

# check if we have a data framme with at least two columns
if (nrow(data) < 1) {
insight::format_error("`data` must be a data frame with at least one row.")
}

# check if we have a data framme with at least two columns
if (ncol(data) < 2) {
insight::format_error("`data` must be a data frame with at least two numeric columns.")
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-row_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test_that("row_count, errors or messages", {
expect_error(expect_warning(row_count(iris, select = "abc")), regex = "must be a valid")
expect_error(expect_warning(row_count(iris, select = "abc", count = 3)), regex = "No columns")
expect_error(row_count(iris[1], count = 3), regex = "with at least")
expect_error(row_count(d_mn[-c(1:4), , drop = FALSE], count = 2), regex = "one row")

Check warning on line 26 in tests/testthat/test-row_count.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-row_count.R,line=26,col=32,[unnecessary_concatenation_linter] Remove unnecessary c() of a constant.
})

test_that("row_count, exact match", {
Expand Down

0 comments on commit b45a517

Please sign in to comment.