aboutsummaryrefslogblamecommitdiff
path: root/pkg/tests/testthat/test_geomean.R
blob: 0cc341651b80f60cd36cb4a26c09ef7f5c394b93 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                            
library(pfm)
context("Geometric mean calculation")

test_that("The geometric mean is correctly calculated", {
  expect_equal(geomean(c(1, 3, 9)), 3)
  expect_equal(geomean(c(0, 3, 9)), 0)
  expect_error(geomean(c(1, 3, NA, 9), na.rm = FALSE), "NA")
  expect_equal(geomean(c(1, 3, NA, 9), na.rm = TRUE), 3)
  expect_error(geomean(c(1, -3, 9)), "positive")
  expect_error(geomean(c(1, -3, NA, 9)), "positive")
})

Contact - Imprint