Skip to content

Commit 0c3d0b1

Browse files
committed
two more test for Date formatting
1 parent 8c7246e commit 0c3d0b1

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016-12-03 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/unitTests/cpp/dates.cpp (Datetime_format): Additional ostream tests
4+
* inst/unitTests/runit.Date.R (test.Date.formating): Ditto
5+
16
2016-11-29 Dirk Eddelbuettel <[email protected]>
27

38
* DESCRIPTION (Version, Date): Roll minor version to 0.12.8.2

inst/unitTests/cpp/dates.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,17 @@ std::string Date_format(Date d, std::string fmt) {
182182
std::string Datetime_format(Datetime d, std::string fmt) {
183183
return d.format(fmt.c_str());
184184
}
185+
186+
// [[Rcpp::export]]
187+
std::string Date_ostream(Date d) {
188+
std::stringstream os;
189+
os << d;
190+
return os.str();
191+
}
192+
193+
// [[Rcpp::export]]
194+
std::string Datetime_ostream(Datetime d) {
195+
std::stringstream os;
196+
os << d;
197+
return os.str();
198+
}

inst/unitTests/runit.Date.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ if (.runThisTest) {
209209
checkEquals(Date_format(d, "%Y/%m/%d"),
210210
format(d, "%Y/%m/%d"),
211211
msg="Date.formating.given.format")
212+
checkEquals(Date_ostream(d),
213+
format(d),
214+
msg="Date.formating.ostream")
212215

213216
Sys.setenv(TZ=oldTZ)
214217
}
@@ -227,6 +230,9 @@ if (.runThisTest) {
227230
checkEquals(Datetime_format(d, "%Y/%m/%d %H:%M:%S"),
228231
format(d, "%Y/%m/%d %H:%M:%OS"),
229232
msg="Datetime.formating.given.format")
233+
checkEquals(Datetime_ostream(d),
234+
format(d, "%Y-%m-%d %H:%M:%OS"),
235+
msg="Datetime.formating.ostream")
230236

231237
Sys.setenv(TZ=oldTZ)
232238
options("digits.secs"=olddigits)

0 commit comments

Comments
 (0)