Skip to content

Commit

Permalink
Develop tests a little more
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Oct 23, 2016
1 parent bcffd56 commit a9a4147
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/testthat/test_austen_books.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ context("Tidy dataframe for books")

suppressPackageStartupMessages(library(dplyr))

test_that("factor order is correct", {
d <- austen_books()
expect_equal(levels(d$book)[1], "Sense & Sensibility")
expect_equal(levels(d$book)[6], "Persuasion")
})

test_that("tidy frame for Austen books is right", {
d <- austen_books() %>%
group_by(book) %>%
summarise(total_lines = n())
expect_equal(nrow(d), 6)
expect_equal(ncol(d), 2)
# the factor levels still in the right order?
expect_equal(as.character(d$book[1]), "Sense & Sensibility")
expect_equal(as.character(d$book[6]), "Persuasion")
# Persuasion has fewer lines than Emma?
expect_lt(d$total_lines[6], d$total_lines[4])
})

0 comments on commit a9a4147

Please sign in to comment.