Skip to content

Commit

Permalink
dedicated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Müller committed Apr 9, 2016
1 parent 384a937 commit 47272e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/testthat/test-expect-output.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,21 @@ test_that("multiline outputs captures and matches", {
test_that("... passed on to grepl", {
expect_success(expect_output(print("X"), "x", ignore.case = TRUE))
})

test_that("expect_output_file works, also with incomplete last line", {
file <- tempfile()
writeLines("Hi!", file)
expect_success(expect_output_file(cat("Hi!"), file))
expect_success(expect_output_file(cat("Hi!\n"), file))
expect_failure(expect_output_file(cat("Hi!\n\n"), file))
expect_failure(expect_output_file(cat("oops"), file))
})

test_that("expect_output_file can update file but does not by default", {
file <- tempfile()
writeLines("Hi!", file)
expect_failure(expect_output_file(cat("oops"), file))
expect_equal(readLines(file), "Hi!")
expect_failure(expect_output_file(cat("oops"), file, update = TRUE))
expect_success(expect_output_file(cat("oops"), file))
})

0 comments on commit 47272e3

Please sign in to comment.