tests/testthat/test-get_3d_cross_prod.R

## Tests of get_3d_cross_prod() are in this file

## Test get_3d_cross_prod()
test_that("get_3d_cross_prod() fails when non-numerics are supplied", {
  expect_error(get_3d_cross_prod("steve"))
  expect_error(get_3d_cross_prod(c("a", "b", "c")))
})

## Set up vectors
v1 <- c(1, 1, 3)
v2 <- c(3, 1, 3)

test_that("get_3d_cross_prod() returns the correct value", {
  expect_equal(
    get_3d_cross_prod(v1, v2),
    c(0, 6, -2))
})

Try the pathviewr package in your browser

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

pathviewr documentation built on March 31, 2023, 5:47 p.m.