-
Notifications
You must be signed in to change notification settings - Fork 320
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
Proposed expectations: expect_nrow(), expect_ncol(), expect_dim() #1423
Comments
Alternatively we might try something like
And
And so on. Maybe the signature could be
instead so that explicitly setting |
My main concern is whether this is a "slippery slope" — i.e. does adding OTOH, I think Maybe it would be better to leave length as a separate expectation, then drop So I think I'm suggesting |
SGTM! I'll work on a PR. If it's possible to assign to me, feel free to do so. |
As noted at r-lib/vctrs#1470, we could re-use
But that's pretty abstruse IMO; the proposed |
testthat::expect_length()
is convenient for testing the size of vectors.A natural extension would seem to be similar expectations for
data.frame
s/matrices/arrays, where expectations likeWould come in handy. For list-extensions like
data.frame
, of courseexpect_length
works, but anexpect_ncol
would also be more readable for this case.Does that make sense to include in
testthat
itself? Happy to file the PR if so.From a quick glance at our particular subset of CRAN, I see 413 usages of
expect_equal(nrow(
, 98 forexpect_equal(ncol(
, and 130 ofexpect_equal(dim(
, so it's clearly used a decent amount already by downstreams.The text was updated successfully, but these errors were encountered: