Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: testNumeric() function treated the matrix as numeric #253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ SEXP attribute_hidden c_check_double(SEXP x, SEXP lower, SEXP upper, SEXP finite
}

SEXP attribute_hidden c_check_numeric(SEXP x, SEXP lower, SEXP upper, SEXP finite, SEXP any_missing, SEXP all_missing, SEXP len, SEXP min_len, SEXP max_len, SEXP unique, SEXP sorted, SEXP names, SEXP typed_missing, SEXP null_ok) {
HANDLE_TYPE_NULL(is_class_numeric(x) || check_typed_missing(x, typed_missing), "numeric", null_ok);
HANDLE_TYPE_NULL(!is_class_matrix(x) && is_class_numeric(x) || check_typed_missing(x, typed_missing), "numeric", null_ok);
ASSERT_TRUE(check_vector_len(x, len, min_len, max_len));
ASSERT_TRUE(check_vector_names(x, names));
ASSERT_TRUE(check_vector_missings(x, any_missing, all_missing));
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_checkNumeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_that("checkNumeric", {
expect_false(testNumeric(1:3, any.missing=FALSE, len=5))
expect_true(testNumeric(1:3, lower = 1L, upper = 3L))
expect_false(testNumeric(1:3, lower = 5))

expect_false(testNumeric(matrix(1:3)))
expect_error(assertNumeric("a"), "numeric")
})

Expand Down