File: test_helpers.R

package info (click to toggle)
r-cran-units 0.8-7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,172 kB
  • sloc: xml: 2,437; cpp: 211; sh: 13; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
test_that("keep_units restores units", {
  x <- set_units(1:5, m)

  expect_identical(x, keep_units(drop_units, x))
})

test_that("keep_units warns when no units are provided", {
  x <- 1:5

  expect_warning(keep_units(sum, x))

  expect_identical(suppressWarnings(keep_units(sum, x)), sum(x))
})

test_that("keep_units sets user-provided units", {
  rate <- set_units(3, "1/min")
  x <- keep_units(rexp, 3, rate, unit=units(1/rate))
  expect_identical(units(x), units(1/rate))

})