Path: blob/master/2019-fall/materials/tutorial_07/tests_tutorial_07.R
2051 views
library(testthat)1library(digest)234test_1.0 <- function(){5test_that('Solution is incorrect', {6expect_that(exists('answer1.0'), is_true())7expect_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 test89})10print("Success!")11}121314test_1.1 <- function(){15test_that('Solution is incorrect', {16expect_that(exists('answer1.1'), is_true())17expect_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 test1819})20print("Success!")21}2223test_2.0 <- function(){24test_that('number_of_rows does not exist', {25expect_that(exists('number_of_rows'), is_true())26})27test_that('The number of rows is incorrect', {28expect_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 test2930})31print("Success!")32}3334test_2.1 <- function(){35test_that('Solution is incorrect', {36expect_equal(nrow(counts), 10)37expect_equal(sum(as.numeric(counts$y)), 55)38})39print("Success!")40}4142test_2.4 <- function(){43test_that('Solution is incorrect', {44expect_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 test4546})47print("Success!")48}495051