| 1 |
test_that("keep_units restores units", { |
| 2 |
x <- set_units(1:5, m) |
| 3 |
|
| 4 |
expect_identical(x, keep_units(drop_units, x)) |
| 5 |
}) |
| 6 |
|
| 7 |
test_that("keep_units warns when no units are provided", { |
| 8 |
x <- 1:5 |
| 9 |
|
| 10 |
expect_warning(keep_units(sum, x)) |
| 11 |
|
| 12 |
expect_identical(suppressWarnings(keep_units(sum, x)), sum(x)) |
| 13 |
}) |
| 14 |
|
| 15 |
test_that("keep_units sets user-provided units", { |
| 16 |
rate <- set_units(3, "1/min") |
| 17 |
x <- keep_units(rexp, 3, rate, unit=units(1/rate)) |
| 18 |
expect_identical(units(x), units(1/rate)) |
| 19 |
|
| 20 |
}) |