Added example snippets of the presentation.
This commit is contained in:
commit
635b784fba
4 files changed
+47
No files matched your search
@@ -0,0 +1,4 @@
|
||||
# Example function to be tested.
|
||||
linear_transformation <- function(x) {
|
||||
return (2*x + 1)
|
||||
}
|
||||
@@ -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