Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2015-01-16 Kevin Ushey <kevinushey@gmail.com>

* inst/include/Rcpp/String.h: fix push_front()
* inst/unitTests/runit.String.R: test
* inst/unitTests/cpp/String.cpp: test

2015-01-15 Kevin Ushey <kevinushey@gmail.com>

* inst/include/Rcpp/platform/sysmacros.h: remove leaked macros
Expand Down
2 changes: 1 addition & 1 deletion inst/include/Rcpp/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace Rcpp {

inline String& push_front( const char* s){
if( is_na() ) return *this ;
setBuffer() ; valid = false ; buffer += s ;
setBuffer() ; valid = false ; buffer = s + buffer;
return *this ;
}
inline String& push_front( const std::string& s){
Expand Down
5 changes: 5 additions & 0 deletions inst/unitTests/cpp/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ List test_compare_Strings( String aa, String bb ){
) ;
}

// [[Rcpp::export]]
String test_push_front(String x) {
x.push_front("abc");
return x;
}
6 changes: 5 additions & 1 deletion inst/unitTests/runit.String.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ if (.runThisTest) {
)
checkEquals( res, target )
}


test.push.front <- function() {
res <- test_push_front("def")
checkIdentical(res, "abcdef")
}
}