Skip to content

Commit 1b10c08

Browse files
committed
new test for #1232
1 parent 54a14cc commit 1b10c08

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2022-10-06 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/tinytest/test_dataframe.R (test.DataFrame.PushZeroLength): Add
4+
new test
5+
* inst/tinytest/cpp/DataFrame.cpp (DataFrame_PushOnEmpty): C++
6+
support for new test
7+
18
2022-10-04 Dirk Eddelbuettel <[email protected]>
29

310
* inst/include/Rcpp/DataFrame.h (set_type_after_push): Allow zero-row

inst/tinytest/cpp/DataFrame.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,17 @@ DataFrame DataFrame_PushZeroLength(){
192192
df1.push_back(v);
193193
return df1;
194194
}
195+
196+
// issue #1232
197+
// [[Rcpp::export]]
198+
Rcpp::DataFrame DataFrame_PushOnEmpty() {
199+
int n = 0;
200+
Rcpp::IntegerVector foo(n);
201+
Rcpp::CharacterVector bar(n);
202+
Rcpp::CharacterVector baz(n);
203+
204+
Rcpp::List ll = Rcpp::List::create(Rcpp::Named("foo") = foo,
205+
Rcpp::Named("bar") = bar);
206+
ll.push_back(baz, "baz");
207+
return Rcpp::DataFrame(ll);
208+
}

inst/tinytest/test_dataframe.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ expect_equal( DataFrame_PushReplicateLength(), df )
113113

114114
# test.DataFrame.PushZeroLength <- function(){
115115
expect_warning( DataFrame_PushZeroLength())
116+
117+
## issue #1232: push on empty data.frame
118+
df <- DataFrame_PushOnEmpty()
119+
expect_equal(ncol(df), 3L)

0 commit comments

Comments
 (0)