Skip to content

Commit ee3d2d1

Browse files
committed
add simple test for message()
1 parent 8992d83 commit ee3d2d1

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* inst/include/Rcpp/api/meat/message.h: Add wrapper for base::message
44
* inst/include/Rcpp/api/meat/meat.h: Include new file
5+
* inst/tinytest/test_misc.R: Simple test
6+
* inst/tinytest/cpp/misc.cpp (messageWrapper): Test support
57

68
2021-02-23 Dirk Eddelbuettel <[email protected]>
79

inst/tinytest/cpp/misc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,8 @@ String testNullableString(Rcpp::Nullable<Rcpp::String> param = R_NilValue) {
224224
else
225225
return String("");
226226
}
227+
228+
// [[Rcpp::export]]
229+
void messageWrapper(SEXP s) {
230+
message(s);
231+
}

inst/tinytest/test_misc.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
## Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
2+
## Copyright (C) 2010 - 2021 Dirk Eddelbuettel and Romain Francois
33
##
44
## This file is part of Rcpp.
55
##
@@ -182,3 +182,7 @@ expect_true(getRcppVersion(devel=TRUE) >= getRcppVersion(devel=FALSE), info="dev
182182
## if need be it can be useful to fail to test e.g. the Docker setup
183183
## commented out now as we prefer to pass when not debugging ;-)
184184
# expect_true(FALSE, info="oh noes")
185+
186+
## test that a message is output as is, and a suppressedMessage is not
187+
expect_equal(capture.output( messageWrapper("ABCdef"), type="message"), "ABCdef")
188+
expect_equal(capture.output( suppressMessages(messageWrapper("ABCdef")), type="message"), character())

0 commit comments

Comments
 (0)