簡體   English   中英

是否可以使用testthat :: expect_output期望回車?

[英]Is it possible to use testthat::expect_output to expect a carriage return?

我正在嘗試測試我的包裹,以確保打印到屏幕上的消息以回車結尾。 當我嘗試匹配最后的回車符時,它永遠不會成功。 有什么辦法可以匹配回車嗎?

library(testthat)
foo <- function() cat("Hello\n")
expect_output(foo(), "Hello\n")
#> Error: `foo\(\)` does not match "Hello\n".
#> Actual value: "Hello"

下面的作品,看起來像是貓的行為

查看一下fill參數的幫助(默認為FALSE)

foo <- function() {cat ("Hello\n",fill=TRUE)}
expect_output(foo(), "Hello\n")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM