tests/testthat/test_throwserror.R

library(lab3package)
library(testthat)
context("euclidian")

test_that("The code throws an error", {
  expect_that(euclidian(c(1000,"a"),c("1000",1000)), throws_error("Error:length of the arguments are not equal to 1 and/or arguments are not numeric"))
  expect_that(euclidian(TRUE,c("1000",1000)), throws_error("Error:length of the arguments are not equal to 1 and/or arguments are not numeric"))
  expect_that(euclidian(5>2,FALSE), throws_error("Error:length of the arguments are not equal to 1 and/or arguments are not numeric"))
  expect_that(euclidian(2,1:10), throws_error("Error:length of the arguments are not equal to 1 and/or arguments are not numeric"))
  expect_that(euclidian(1,"hello"), throws_error("Error:length of the arguments are not equal to 1 and/or arguments are not numeric"))
})
rebinhosini/AdvancedR documentation built on May 27, 2019, 4:01 a.m.