tests/testthat/test-molec_wt.R

# Run all tests in this script:
## testthat::test_file(file.path("tests", "testthat", "test-molec_wt.R"))

# Error testing
test_that("Only accepts correct inputs", {
  expect_error(molec_wt())
  expect_error(molec_wt(element = "not_element"))
  expect_error(molec_wt(element = 119))
})

# Output testing
test_that("Outputs are correct", {
  expect_equal(molec_wt(element = "Oxygen"), 15.999)
  expect_equal(molec_wt(element = "hydrogen"), 1.007)
  expect_equal(molec_wt(element = "plutonium"), 244)
})

Try the scicomptools package in your browser

Any scripts or data that you put into this service are public.

scicomptools documentation built on Nov. 1, 2024, 1:06 a.m.