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

Add allow_infinite to check_number_whole() #1593

Merged
merged 1 commit into from
Mar 13, 2023
Merged
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
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@

## Miscellaneous fixes and features

* New `check_logical()` in `standalone-types-check.R` (#1587, @mgirlich).
* New `check_data_frame()` and `check_logical()` functions in
`standalone-types-check.R` (#1587, @mgirlich).

* Added `allow_infinite` argument to `check_number_whole()` (#1588, @mgirlich).

* The lifecycle standalone file has been updated to match the modern
lifecycle tools.
Expand Down
8 changes: 6 additions & 2 deletions R/standalone-types-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
#
# ## Changelog
#
# 2023-03-13:
# - Added `allow_infinite` argument to `check_number_whole()`.
# - Added `check_data_frame()`.
#
# 2023-03-07:
# - Added dependency on rlang (>= 1.1.0).
# - Added `check_data_frame()`.
#
# 2023-02-15:
# - Added `check_logical()`.
Expand Down Expand Up @@ -199,6 +202,7 @@ check_number_whole <- function(x,
...,
min = NULL,
max = NULL,
allow_infinite = FALSE,
allow_na = FALSE,
allow_null = FALSE,
arg = caller_arg(x),
Expand All @@ -211,7 +215,7 @@ check_number_whole <- function(x,
allow_decimal = FALSE,
min,
max,
allow_infinite = FALSE,
allow_infinite,
allow_na,
allow_null
))) {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-standalone-types-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ test_that("`check_number_whole()` checks", {
expect_null(check_number_whole(na_dbl, allow_na = TRUE))
expect_null(check_number_whole(na_int, allow_na = TRUE))
expect_null(check_number_whole(NULL, allow_null = TRUE))
expect_null(check_number_whole(Inf, allow_infinite = TRUE))
expect_null(check_number_whole(-Inf, allow_infinite = TRUE))

check_number_whole(0, max = 0)
check_number_whole(0, min = 0)
Expand Down