tests/testthat/test_reduction.R

context("Vector reduction")
library(dst)
test_that("reduction", {
  # T1 Apply reduction to a numeric vector
  result <- reduction(c(1,2,3,4), f="-")
  expect_equal(result, -8)
  # T2 Apply reduction to a logical vector
  result <-  reduction(c(1,0,1,1,0), f="&")
  expect_equal(result, FALSE)
  #T3 Apply reduction to a string vector
  result <- reduction(c("a", "b", "c"), f="paste")
  expect_equal(result, "a b c")
})

Try the dst package in your browser

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

dst documentation built on Nov. 16, 2023, 5:08 p.m.