Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
UBC-DSCI
GitHub Repository: UBC-DSCI/dsci-100-assets
Path: blob/master/2019-fall/materials/tutorial_07/tests_tutorial_07.R
2051 views
1
library(testthat)
2
library(digest)
3
4
5
test_1.0 <- function(){
6
test_that('Solution is incorrect', {
7
expect_that(exists('answer1.0'), is_true())
8
expect_equal(digest(answer1.0), 'c1f86f7430df7ddb256980ea6a3b57a4') # we hid the answer to the test here so you can't see it, but we can still run the test
9
10
})
11
print("Success!")
12
}
13
14
15
test_1.1 <- function(){
16
test_that('Solution is incorrect', {
17
expect_that(exists('answer1.1'), is_true())
18
expect_equal(digest(answer1.1), '475bf9280aab63a82af60791302736f6') # we hid the answer to the test here so you can't see it, but we can still run the test
19
20
})
21
print("Success!")
22
}
23
24
test_2.0 <- function(){
25
test_that('number_of_rows does not exist', {
26
expect_that(exists('number_of_rows'), is_true())
27
})
28
test_that('The number of rows is incorrect', {
29
expect_equal(digest(number_of_rows), '9ecacdf4df8df05e2501eb3f18bd13ab') # we hid the answer to the test here so you can't see it, but we can still run the test
30
31
})
32
print("Success!")
33
}
34
35
test_2.1 <- function(){
36
test_that('Solution is incorrect', {
37
expect_equal(nrow(counts), 10)
38
expect_equal(sum(as.numeric(counts$y)), 55)
39
})
40
print("Success!")
41
}
42
43
test_2.4 <- function(){
44
test_that('Solution is incorrect', {
45
expect_equal(digest(label_102[[1]]), '7951b4c16d8f371c0ff9d97401f46907') # we hid the answer to the test here so you can't see it, but we can still run the test
46
47
})
48
print("Success!")
49
}
50
51