[PATCH 1/3] libstdc++: Add time_get::get support.

Jonathan Wakely jwakely@redhat.com
Mon Dec 22 13:44:00 GMT 2014


On 15/04/14 23:19 +0200, Rüdiger Sonderfeld wrote:
>+  TESTHEAD("check broken format");
>+  iss.str("2014-04-14 01:09:35");
>+  format = "%";
>+  ret = tget.get(istreambuf_iterator<char>(iss), end, iss, err, &time,
>+                 format.data(), format.data()+format.size());
>+  VERIFY(err == ios_base::failbit);
>+
>+  TESTHEAD("check single format letter version");
>+  iss.str("2020");
>+  ret = tget.get(istreambuf_iterator<char>(iss), end, iss, err, &time, 'Y');
>+  VERIFY(err == ios_base::goodbit);
>+  VERIFY(time.tm_year == 120);
>+  VERIFY(ret == end);
>+
>+  TESTHEAD("check skipping of space");
>+  iss.str("2010    07 01");
>+  format = "%Y %m %d";
>+  ret = tget.get(istreambuf_iterator<char>(iss), end, iss, err, &time,
>+                 format.data(), format.data()+format.size());
>+  VERIFY(err == ios_base::goodbit);
>+  VERIFY(time.tm_year == 110);
>+  VERIFY(time.tm_mon == 7);

This fails because tm_mon is zero-indexed, so the result is 6

>+  VERIFY(time.tm_mday == 1);
>+  VERIFY(ret == end);
>+
>+  TESTHEAD("check mismatch");
>+  iss.str("year: 1970");
>+  format = "jahr: 1970";
>+  ret = tget.get(istreambuf_iterator<char>(iss), end, iss, err, &time,
>+                 format.data(), format.data()+format.size());
>+  VERIFY(err == ios_base::failbit);
>+  VERIFY(ret == istreambuf_iterator<char>(iss));
>+
>+  TESTHEAD("check case insensitive match");
>+  iss.str("yEaR: 1980");
>+  format = "YeAR: 1980";
>+  ret = tget.get(istreambuf_iterator<char>(iss), end, iss, err, &time,
>+                 format.data(), format.data()+format.size());
>+  VERIFY(err == ios_base::goodbit);
>+  VERIFY(ret == end);
>+  VERIFY(time.tm_year == 80);

This test can never pass because the format has 1980 instead of %Y

Apparently the tests in this patch have never been run :-(

I think I've fixed them now though, and am committing the attached
patch to trunk.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 25583 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20141222/c8aa7f08/attachment.bin>


More information about the Libstdc++ mailing list