library(tibble)
library(dplyr)
library(testthat)
df <- tibble(
year = 2019,
batsman = "MS Dhoni",
strike_rate = 134.63
)
test_that("check strike rate", {
expect_equal(df, strike_rate("MS Dhoni", 2019))
})
test_that("check for invalid input types", {
expect_error(
strike_rate(00, 2016),
regexp = "be a character"
)
expect_error(
strike_rate("V Kohli", "2016"),
regexp = "be a numeric"
)
})
test_that("check for when data not found", {
expect_error(
strike_rate("Kohli", 2016),
regexp = "not found"
)
expect_error(
strike_rate("V Kohli", 2000),
regexp = "not found"
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.