Added example snippets of the presentation.
This commit is contained in:
4
example/example.R
Normal file
4
example/example.R
Normal file
@@ -0,0 +1,4 @@
|
||||
# Example function to be tested.
|
||||
linear_transformation <- function(x) {
|
||||
return (2*x + 1)
|
||||
}
|
12
example/test/test_linear_transformation.R
Normal file
12
example/test/test_linear_transformation.R
Normal file
@@ -0,0 +1,12 @@
|
||||
source("../example.R", chdir=TRUE)
|
||||
library(testthat)
|
||||
|
||||
test_that("Real numbers are transformed to odd numbers.", {
|
||||
expect_equal(linear_transformation(3) %% 2, 1)
|
||||
expect_equal(linear_transformation(4) %% 2, 1)
|
||||
})
|
||||
|
||||
test_that("Positive numbers remain positive.", {
|
||||
expect_true(linear_transformation(3) > 0)
|
||||
expect_true(linear_transformation(10) > 0)
|
||||
})
|
Reference in New Issue
Block a user