Skip to content

Commit 8aafe7c

Browse files
committed
test: cover signed size floor division
1 parent f6c9a2f commit 8aafe7c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/testthat/test-sizes-arithmetic.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ test_that("size integer division evaluates numeric operands before casting", {
8080
expect_identical(qfn(3.9, 1.9), fn(3.9, 1.9))
8181
})
8282

83+
test_that("size integer division rounds negative quotients down", {
84+
fn <- function(x, y) {
85+
declare(type(x = integer(1)), type(y = integer(1)))
86+
double((x %/% y) + 3L)
87+
}
88+
89+
expect_quick_identical(fn, list(-3L, 2L))
90+
})
91+
8392
test_that("size modulo uses the divisor's sign", {
8493
fn <- function(x, y) {
8594
declare(type(x = integer(1)), type(y = integer(1)))

0 commit comments

Comments
 (0)