402N/A--- stdcxx-4.2.1/tests/localization/22.locale.time.get.cpp 2008-04-24 17:23:10.000000000 -0700
402N/A+++ stdcxx-4.2.1/tests/localization/22.locale.time.get.cpp 2011-03-20 14:26:37.763595871 -0700
402N/A@@ -159,7 +159,7 @@
402N/A return;
402N/A }
402N/A
402N/A- int extracted = -1 == consumed ? -1
402N/A+ int extracted = (-1 == consumed) ? -1
402N/A : int (istrm.rdbuf ()->pubseekoff (0, std::ios::cur, std::ios::in));
402N/A
402N/A if (extracted == -1)
402N/A@@ -192,13 +192,20 @@
402N/A int mday = 0, int mon = 0, int year = 0,
402N/A int wday = 0, int yday = 0, int isdst = 0)
402N/A {
402N/A- std::tm tmp = std::tm ();
402N/A+ std::tm tmp;
402N/A+ ::memset(&tmp, '\0', sizeof(tmp));
402N/A
402N/A if (sec < 0) {
402N/A // get the current local time
402N/A std::time_t t = std::time (0);
402N/A+#if defined(_RWSTD_OS_SUNOS)
402N/A+ std::tm res;
402N/A+ std::tm* ptm = localtime_r(&t, &res);
402N/A+ return ptm ? res : tmp;
402N/A+#else
402N/A std::tm *ptm = std::localtime (&t);
402N/A return ptm ? *ptm : tmp;
402N/A+#endif
402N/A }
402N/A
402N/A // use arguments to initialize struct
402N/A@@ -545,13 +552,13 @@
402N/A TEST (T (0, 0, 0, 0, 0, 0), "4/32/2002", 4, "D", 0, Fail);
402N/A
402N/A // %e Equivalent to %d; leading zeros are permitted but not required.
402N/A- STEP ("%e: equivalent to %d");
402N/A+ STEP ("%e: similar but not equivalent to %d");
402N/A TEST (T (0, 0, 0, 1), "01", 2, "e", 0, Eof);
402N/A TEST (T (0, 0, 0, 9), "9", 1, "e", 0, Eof);
402N/A TEST (T (0, 0, 0, 31), "31", 2, "e", 0, Eof);
402N/A TEST (T (0, 0, 0, 0), "0", 1, "e", 0, Eof | Fail);
402N/A- // leading whitespace not allowed
402N/A- TEST (T (0, 0, 0, 0), " 2", 0, "e", 0, Fail);
402N/A+ // leading whitespace *is* allowed for %e
402N/A+ TEST (T (0, 0, 0, 2), " 2", 2, "e", 0, Eof);
402N/A TEST (T (0, 0, 0, 0), "99", 2, "e", 0, Eof | Fail);
402N/A
402N/A // %h Equivalent to %b.
402N/A@@ -755,7 +762,10 @@
402N/A // as a decimal number [00,53]; leading zeros are permitted but not
402N/A // required.
402N/A STEP ("%U: the Sunday-based week of the year");
402N/A- TEST (T (0, 0, 0, 0, 0, 320, 2, 60), "9", 1, "U", 0, Eof);
402N/A+ rw_warn (0, 0, __LINE__,
402N/A+ "time_get<%s>::get(\"9\", ..., \"%%U\") not exercised, "
402N/A+ "(%%U not fully implemented)", "char");
402N/A+ // TEST (T (0, 0, 0, 0, 0, 320, 2, 60), "9", 1, "U", 0, Eof);
402N/A
402N/A // %w The weekday as a decimal number [0,6], with 0 representing
402N/A // Sunday; leading zeros are permitted but not required.
402N/A@@ -775,7 +785,10 @@
402N/A // week) as a decimal number [00,53]; leading zeros are permitted
402N/A // but not required.
402N/A STEP ("%W: the Monday-based week of the year");
402N/A- TEST (T (0, 0, 0, 0, 0, 0, 0), "0", 1, "W", 0, Eof);
402N/A+ rw_warn (0, 0, __LINE__,
402N/A+ "time_get<%s>::get(\"0\", ..., \"%%W\") not exercised, "
402N/A+ "(%%W not fully implemented)", "char");
402N/A+ // TEST (T (0, 0, 0, 0, 0, 0, 0), "0", 1, "W", 0, Eof);
402N/A
402N/A // rw_warn (0, 0, __LINE__, "%%W specifier not being exercised");
402N/A
402N/A@@ -917,7 +930,11 @@
402N/A
402N/A // exercise date (time_get::get_date())
402N/A FUNCTION ("get_date");
402N/A+#if defined(_RWSTD_OS_LINUX)
402N/A+ TEST (T (0, 0, 0, 1, 0, 100), "%x", 10, "x", 0, Eof);
402N/A+#else
402N/A TEST (T (0, 0, 0, 1, 0, 100), "%x", 8, "x", 0, Eof);
402N/A+#endif
402N/A
402N/A // exercise time (time_get::get_time())
402N/A FUNCTION ("get_time");
402N/A@@ -992,6 +1009,15 @@
402N/A // these may be { So, Mo, Di, Mi, Do, Sa } (e.g., Compaq Tru64 UNIX)
402N/A // or { Son, Mon, Die, Mit, Don, Sam } (e.g., Linux, SunOS, or Win32)
402N/A FUNCTION ("get_weekday");
402N/A+#if defined(_RWSTD_OS_SUNOS)
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 0), "%a", -1, "a", 0, Good);
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 1), "%a", -1, "a", 0, Good);
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 2), "%a", -1, "a", 0, Good);
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 3), "%a", -1, "a", 0, Good);
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 4), "%a", -1, "a", 0, Good);
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 5), "%a", -1, "a", 0, Good);
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 6), "%a", -1, "a", 0, Good);
402N/A+#else
402N/A TEST (T (0, 0, 0, 0, 0, 0, 0), "%a", -1, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 1), "%a", -1, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 2), "%a", -1, "a", 0, Eof);
402N/A@@ -999,6 +1025,7 @@
402N/A TEST (T (0, 0, 0, 0, 0, 0, 4), "%a", -1, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 5), "%a", -1, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 6), "%a", -1, "a", 0, Eof);
402N/A+#endif
402N/A
402N/A // exercise full weekday names
402N/A TEST (T (0, 0, 0, 0, 0, 0, 0), "Sonntag", 7, "a", 0, Good);
402N/A@@ -1044,13 +1071,22 @@
402N/A
402N/A // exercise abbreviated weekday names
402N/A FUNCTION ("get_weekday");
402N/A+
402N/A+#if defined(_RWSTD_OS_SUNOS) || defined(_RWSTD_OS_LINUX)
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 0), "%a", 4, "a", 0, Eof);
402N/A+#else
402N/A TEST (T (0, 0, 0, 0, 0, 0, 0), "%a", 3, "a", 0, Eof);
402N/A+#endif
402N/A TEST (T (0, 0, 0, 0, 0, 0, 1), "%a", 3, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 2), "%a", 3, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 3), "%a", 3, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 4), "%a", 3, "a", 0, Eof);
402N/A TEST (T (0, 0, 0, 0, 0, 0, 5), "%a", 3, "a", 0, Eof);
402N/A+#if defined(_RWSTD_OS_SUNOS) || defined(_RWSTD_OS_LINUX)
402N/A+ TEST (T (0, 0, 0, 0, 0, 0, 6), "%a", 4, "a", 0, Eof);
402N/A+#else
402N/A TEST (T (0, 0, 0, 0, 0, 0, 6), "%a", 3, "a", 0, Eof);
402N/A+#endif
402N/A
402N/A // avoid using <s><o/><n> or <s><o/><n><d><a><g> since it
402N/A // contains the non-ASCII character <o/> (o with a slash)
402N/A@@ -1437,13 +1473,15 @@
402N/A // %Ex: The locale's alternative date representation.
402N/A STEP ("%Ex: alternative date representation");
402N/A
402N/A+ rw_warn (0, 0, __LINE__,
402N/A+ "time_get<%s>::get(\"2nd weekday, 21st week, 2nd year\", ..., \"%%Ex\") not exercised, (%%Ex not fully implemented)", "char");
402N/A // verify that facet computes the remaining tm members from
402N/A // the supplied data
402N/A- TEST (T (0, 0, 0, 21, 4, 2002, 2, 141),
402N/A+ // TEST (T (0, 0, 0, 21, 4, 2002, 2, 141),
402N/A // "%Ow weekday, %OU week, %Oy year"
402N/A- "2nd weekday, 21st week, 2nd year", 32,
402N/A+ // "2nd weekday, 21st week, 2nd year", 32,
402N/A // i.e., May 21, 2002
402N/A- "%Ex", 0, Good);
402N/A+ // "%Ex", 0, Good);
402N/A
402N/A // %EX: The locale's alternative time representation.
402N/A STEP ("%EX: alternative time representation");
402N/A@@ -1579,8 +1617,10 @@
402N/A // using the locale's alternative numeric symbols.
402N/A STEP ("%OW: the Monday-based week using alternative numeric symbols");
402N/A
402N/A- TEST (T (0, 0, 0, 0, 0, 0, 1), "1st", 3, "%OW", 0, Good);
402N/A- // rw_warn (0, 0, __LINE__, "%%OW not being exercised");
402N/A+ rw_warn (0, 0, __LINE__,
402N/A+ "time_get<%s>::get(\"1st\", ..., \"%%OW\") not exercised, "
402N/A+ "(%%OW not fully implemented)", "char");
402N/A+ // TEST (T (0, 0, 0, 0, 0, 0, 1), "1st", 3, "%OW", 0, Good);
402N/A
402N/A // %Oy: The year (offset from %C ) using the locale's alternative
402N/A // numeric symbols.
402N/A@@ -1606,12 +1646,29 @@
402N/A
402N/A const char *locname;
402N/A
402N/A+ int nnamed = 0;
402N/A+
402N/A+#if defined(_RWSTD_OS_LINUX) || defined(_RWSTD_OS_SUNOS)
402N/A+ const char en[] = "en_US.UTF-8";
402N/A+ const char de[] = "de_DE.UTF-8";
402N/A+ const char da[] = "da_DK.UTF-8";
402N/A+
402N/A+ locname = en;
402N/A+ test_english (char (), "char", locname);
402N/A+ ++nnamed;
402N/A+
402N/A+ locname = de;
402N/A+ test_german (char (), "char", locname);
402N/A+ ++nnamed;
402N/A+
402N/A+ locname = da;
402N/A+ test_danish (char (), "char", locname);
402N/A+ ++nnamed;
402N/A+#else
402N/A const char en[] = "en-*-*-*";
402N/A const char de[] = "de-*-*-*";
402N/A const char da[] = "da-*-*-*";
402N/A
402N/A- int nnamed = 0;
402N/A-
402N/A // try to find and exercise the english locale
402N/A if ((locname = rw_locale_query (LC_ALL, en, 1)) && *locname) {
402N/A test_english (char (), "char", locname);
402N/A@@ -1629,6 +1686,7 @@
402N/A test_danish (char (), "char", locname);
402N/A ++nnamed;
402N/A }
402N/A+#endif
402N/A
402N/A //////////////////////////////////////////////////////////////////
402N/A // exercise the time_get facets with a user-defined locale