Don't let time_put test use implementation dependent constructs.

The time_put test doesn't seem to work on Linux and CloudABI. For Linux
we already have an XFAIL. Closer inspection seems to reveal that this
test does not pass for a couple of reasons.

First of all, the tm_yday field is set to an invalid value. The
strftime() function doesn't behave consistently across platforms in case
the values in the tm structure are incoherent. Fix up this field to have
the value 121, which corresponds with tm_mday, tm_mon and tm_year. This
of course affects the output of time_put for some modifiers, so update
the tests accordingly.

Second, some of the tests actually use modifiers that are only present
on BSD derived systems. They are not part of the C standard/POSIX.
Simply remove them.

Finally, some of the tests actually use invalid modifiers, causing a
malformed format string to be passed to strftime(). Remove these tests
as well.

Differential Revision:	http://reviews.llvm.org/D8349


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@233262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ed Schouten 2015-03-26 08:38:00 +00:00
parent 70e13a9ca8
commit 3f86893b6c

View File

@ -14,9 +14,6 @@
// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
// char format, char modifier = 0) const;
// TODO: investigation needed
// XFAIL: linux-gnu
#include <locale>
#include <cassert>
#include "test_iterators.h"
@ -36,7 +33,7 @@ int main()
const my_facet f(1);
char str[200];
output_iterator<char*> iter;
tm t = {0};
tm t = {};
t.tm_sec = 6;
t.tm_min = 3;
t.tm_hour = 13;
@ -44,7 +41,7 @@ int main()
t.tm_mon = 4;
t.tm_year = 109;
t.tm_wday = 6;
t.tm_yday = -1;
t.tm_yday = 121;
t.tm_isdst = 1;
std::ios ios(0);
{
@ -160,12 +157,12 @@ int main()
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U', 'O');
std::string ex(str, iter.base());
assert(ex == "00");
assert(ex == "17");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V', 'O');
std::string ex(str, iter.base());
assert(ex == "52");
assert(ex == "18");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w', 'O');
@ -175,18 +172,13 @@ int main()
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W', 'O');
std::string ex(str, iter.base());
assert(ex == "00");
assert(ex == "17");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'O');
std::string ex(str, iter.base());
assert(ex == "09");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'B', 'O');
std::string ex(str, iter.base());
assert(ex == "May");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e');
std::string ex(str, iter.base());
@ -200,12 +192,12 @@ int main()
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'G');
std::string ex(str, iter.base());
assert(ex == "2008");
assert(ex == "2009");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'g');
std::string ex(str, iter.base());
assert(ex == "08");
assert(ex == "09");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H');
@ -225,17 +217,7 @@ int main()
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'j');
std::string ex(str, iter.base());
assert(ex == "000");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'k');
std::string ex(str, iter.base());
assert(ex == "13");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'l');
std::string ex(str, iter.base());
assert(ex == " 1");
assert(ex == "122");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M');
@ -272,11 +254,6 @@ int main()
std::string ex(str, iter.base());
assert(ex == "06");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 's');
std::string ex(str, iter.base());
// assert(ex == "1241283786"); depends on time zone
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'T');
std::string ex(str, iter.base());
@ -290,7 +267,7 @@ int main()
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U');
std::string ex(str, iter.base());
assert(ex == "00");
assert(ex == "17");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u');
@ -300,17 +277,12 @@ int main()
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V');
std::string ex(str, iter.base());
assert(ex == "52");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'v');
std::string ex(str, iter.base());
assert(ex == " 2-May-2009");
assert(ex == "18");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W');
std::string ex(str, iter.base());
assert(ex == "00");
assert(ex == "17");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w');
@ -357,14 +329,4 @@ int main()
std::string ex(str, iter.base());
assert(ex == "%");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, '%', 'J');
std::string ex(str, iter.base());
assert(ex == "J%");
}
{
iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'J');
std::string ex(str, iter.base());
assert(ex == "J");
}
}