-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from r2evans/add/26-return-char
Add/26 return char
- Loading branch information
Showing
7 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
library(logger) | ||
library(testthat) | ||
|
||
## save current settings so that we can reset later | ||
formatter <- log_formatter() | ||
appender <- log_appender() | ||
|
||
context('return value') | ||
|
||
t <- tempfile() | ||
log_appender(appender_file(t)) | ||
|
||
glue_or_sprintf_result <- c( | ||
"Hi foo, did you know that 2*4=8?", | ||
"Hi bar, did you know that 2*4=8?") | ||
|
||
test_that("return value is formatted string", { | ||
log_formatter(formatter_glue) | ||
expect_equal(log_info('pi is {round(pi, 2)}')[[1]]$message, 'pi is 3.14') | ||
expect_match(log_info('pi is {round(pi, 2)}')[[1]]$record, 'INFO [[0-9: -]*] pi is 3.14') | ||
log_formatter(formatter_paste, index = 2) | ||
expect_equal(log_info('pi is {round(pi, 2)}')[[1]]$message, 'pi is 3.14') | ||
expect_equal(log_info('pi is {round(pi, 2)}')[[2]]$message, 'pi is {round(pi, 2)}') | ||
}) | ||
|
||
## reset settings | ||
unlink(t) | ||
delete_logger_index(index = 2) | ||
log_formatter(formatter) | ||
log_appender(appender) |