Patchwork [v1] Add Reiwa era tests to time/tst-strftime3.c

login
register
mail settings
Submitter DJ Delorie
Date April 1, 2019, 7:28 p.m.
Message ID <xn8swto78p.fsf@greed.delorie.com>
Download mbox | patch
Permalink /patch/32123/
State New
Headers show

Comments

DJ Delorie - April 1, 2019, 7:28 p.m.
Conditional, of course, on bz24405 making the era change,
and someone verifying the results are correct ;-)

2019-04-01  DJ Delorie  <dj@delorie.com>

	* time/tst-strftime3.c: Add Reiwa era tests.
Carlos O'Donell - April 1, 2019, 8:53 p.m.
On 4/1/19 3:28 PM, DJ Delorie wrote:
> Conditional, of course, on bz24405 making the era change,
> and someone verifying the results are correct;-)

I have reviewed bug 24405 changes as requested by TAMUKI-san
and have ACK'd them for master.

> 2019-04-01  DJ Delorie<dj@delorie.com>
> 
> 	* time/tst-strftime3.c: Add Reiwa era tests.
> 

OK for master with the following changes:
- Fix comments.
- Wait for ja_JP fix to land.

Reviewed-by: Carlos O'Donell  <carlos@redhat.com>

> diff --git a/time/tst-strftime3.c b/time/tst-strftime3.c
> index a4c427b3b6..22e2982d4b 100644
> --- a/time/tst-strftime3.c
> +++ b/time/tst-strftime3.c
> @@ -291,6 +291,62 @@ const Data data[] = {
>       1990, Jan,  1, Mon, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
>       /* <U5E73><U6210>02<U5E74> 平成02年 */
>       "\xca\xbf\xc0\xae""02\xc7\xaf" },
> +
> +
> +  { "Japanese era change, 2019, before transition year",
> +    2018, Dec, 31, Mon, 12, 00, 00, "ja_JP.UTF-8", "%EY",
> +    /* <U5E73><U6210>30<U5E74> 昭和30年 */
> +    "\xe5\xb9\xb3\xe6\x88\x90""30\xe5\xb9\xb4" },

Comment wrong. Should be "平成30年"

Data is correct (or test would fail).

> +  { "Japanese era change, 2019, start of transition year",
> +    2019, Jan,  1, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
> +    /* <U5E73><U6210>30<U5E74> 昭和31年 */
> +    "\xe5\xb9\xb3\xe6\x88\x90""31\xe5\xb9\xb4" },

Comment wrong. Should be "平成31年"

Data is correct (or test would fail).

> +
> +  { "Japanese era change, 2019, before transition",
> +    2019, Apr, 30, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
> +    /* <U5E73><U6210>30<U5E74> 昭和31年 */
> +    "\xe5\xb9\xb3\xe6\x88\x90""31\xe5\xb9\xb4" },

Comment wrong. Should be "平成31年"

Data is correct (or test would fail).

> +  { "Japanese era change, 2019, after transition",
> +    2019, May,  1, Wed, 12, 00, 00, "ja_JP.UTF-8", "%EY",
> +    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
> +    "\xe4\xbb\xa4\xe5\x92\x8c\xe5\x85\x83\xe5\xb9\xb4" },

Comment is correct. First year correct.

Data is correct.

> +  { "Japanese era change, 2019, end of transition year",
> +    2019, Dec, 31, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
> +    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
> +    "\xe4\xbb\xa4\xe5\x92\x8c\xe5\x85\x83\xe5\xb9\xb4" },

Comment is correct.

Data is correct.

> +  { "Japanese era change, 2019, after transition year",
> +    2020, Jan,  1, Wed, 12, 00, 00, "ja_JP.UTF-8", "%EY",
> +    /* <U4EE4><U548C>02<U5E74> 令和02年 */
> +    "\xe4\xbb\xa4\xe5\x92\x8c""02\xe5\xb9\xb4" },
> +

Comment is correct.

Data is correct with padding.

> +
> +  { "Japanese era change, 2019, before transition year",
> +    2018, Dec, 31, Mon, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
> +    /* <U5E73><U6210>30<U5E74> 昭和30年 */
> +    "\xca\xbf\xc0\xae""30\xc7\xaf" },
> +  { "Japanese era change, 2019, start of transition year",
> +    2019, Jan,  1, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
> +    /* <U5E73><U6210>30<U5E74> 昭和31年 */
> +    "\xca\xbf\xc0\xae""31\xc7\xaf" },
> +
> +  { "Japanese era change, 2019, before transition",
> +    2019, Apr, 30, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
> +    /* <U5E73><U6210>30<U5E74> 昭和31年 */
> +    "\xca\xbf\xc0\xae""31\xc7\xaf" },

The three above need comment correct.

> +  { "Japanese era change, 2019, after transition",
> +    2019, May,  1, Wed, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
> +    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
> +    "\xce\xe1\xcf\xc2\xb8\xb5\xc7\xaf" },
> +
> +  { "Japanese era change, 2019, end of transition year",
> +    2019, Dec, 31, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
> +    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
> +    "\xce\xe1\xcf\xc2\xb8\xb5\xc7\xaf" },
> +  { "Japanese era change, 2019, after transition year",
> +    2020, Jan,  1, Wed, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
> +    /* <U4EE4><U548C>02<U5E74> 令和02年 */
> +    "\xce\xe1\xcf\xc2""02\xc7\xaf" },
>   };
>   
>   #define NDATA array_length(data)
Steve Ellcey - April 2, 2019, 10:36 p.m.
On Mon, 2019-04-01 at 15:28 -0400, DJ Delorie wrote:
> Conditional, of course, on bz24405 making the era change,

> and someone verifying the results are correct ;-)

> 

> 2019-04-01  DJ Delorie  <dj@delorie.com>

> 

> 	* time/tst-strftime3.c: Add Reiwa era tests.


DJ,

I am building ToT glibc with ToT gcc and during glibc testing I got
this error:

tst-strftime3.c: In function ‘tm_to_printed’:
tst-strftime3.c:443:62: error: ‘%s’ directive output may be truncated writing up to 49 bytes into a region of size between 0 and 30 [-Werror=format-truncation=]
  443 |   snprintf (buffer, TMBUFLEN, "%04d/%02d/%02d %02d:%02d:%02d %s",
      |                                                              ^~
tst-strftime3.c:443:3: note: ‘snprintf’ output between 21 and 122 bytes into a destination of size 50
  443 |   snprintf (buffer, TMBUFLEN, "%04d/%02d/%02d %02d:%02d:%02d %s",
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  444 |      tm->tm_year + 1900,
      |      ~~~~~~~~~~~~~~~~~~~
  445 |      tm->tm_mon + 1,
      |      ~~~~~~~~~~~~~~~
  446 |      tm->tm_mday,
      |      ~~~~~~~~~~~~
  447 |      tm->tm_hour,
      |      ~~~~~~~~~~~~
  448 |      tm->tm_min,
      |      ~~~~~~~~~~~
  449 |      tm->tm_sec,
      |      ~~~~~~~~~~~
  450 |      wn);
      |      ~~~

Patch

diff --git a/time/tst-strftime3.c b/time/tst-strftime3.c
index a4c427b3b6..22e2982d4b 100644
--- a/time/tst-strftime3.c
+++ b/time/tst-strftime3.c
@@ -291,6 +291,62 @@  const Data data[] = {
     1990, Jan,  1, Mon, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
     /* <U5E73><U6210>02<U5E74> 平成02年 */
     "\xca\xbf\xc0\xae""02\xc7\xaf" },
+
+
+  { "Japanese era change, 2019, before transition year",
+    2018, Dec, 31, Mon, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+    /* <U5E73><U6210>30<U5E74> 昭和30年 */
+    "\xe5\xb9\xb3\xe6\x88\x90""30\xe5\xb9\xb4" },
+  { "Japanese era change, 2019, start of transition year",
+    2019, Jan,  1, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+    /* <U5E73><U6210>30<U5E74> 昭和31年 */
+    "\xe5\xb9\xb3\xe6\x88\x90""31\xe5\xb9\xb4" },
+
+  { "Japanese era change, 2019, before transition",
+    2019, Apr, 30, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+    /* <U5E73><U6210>30<U5E74> 昭和31年 */
+    "\xe5\xb9\xb3\xe6\x88\x90""31\xe5\xb9\xb4" },
+  { "Japanese era change, 2019, after transition",
+    2019, May,  1, Wed, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+    "\xe4\xbb\xa4\xe5\x92\x8c\xe5\x85\x83\xe5\xb9\xb4" },
+
+  { "Japanese era change, 2019, end of transition year",
+    2019, Dec, 31, Tue, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+    "\xe4\xbb\xa4\xe5\x92\x8c\xe5\x85\x83\xe5\xb9\xb4" },
+  { "Japanese era change, 2019, after transition year",
+    2020, Jan,  1, Wed, 12, 00, 00, "ja_JP.UTF-8", "%EY",
+    /* <U4EE4><U548C>02<U5E74> 令和02年 */
+    "\xe4\xbb\xa4\xe5\x92\x8c""02\xe5\xb9\xb4" },
+
+  
+  { "Japanese era change, 2019, before transition year",
+    2018, Dec, 31, Mon, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+    /* <U5E73><U6210>30<U5E74> 昭和30年 */
+    "\xca\xbf\xc0\xae""30\xc7\xaf" },
+  { "Japanese era change, 2019, start of transition year",
+    2019, Jan,  1, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+    /* <U5E73><U6210>30<U5E74> 昭和31年 */
+    "\xca\xbf\xc0\xae""31\xc7\xaf" },
+
+  { "Japanese era change, 2019, before transition",
+    2019, Apr, 30, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+    /* <U5E73><U6210>30<U5E74> 昭和31年 */
+    "\xca\xbf\xc0\xae""31\xc7\xaf" },
+  { "Japanese era change, 2019, after transition",
+    2019, May,  1, Wed, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+    "\xce\xe1\xcf\xc2\xb8\xb5\xc7\xaf" },
+
+  { "Japanese era change, 2019, end of transition year",
+    2019, Dec, 31, Tue, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+    /* <U4EE4><U548C><U5143><U5E74> 令和元年 */
+    "\xce\xe1\xcf\xc2\xb8\xb5\xc7\xaf" },
+  { "Japanese era change, 2019, after transition year",
+    2020, Jan,  1, Wed, 12, 00, 00, "ja_JP.EUC-JP", "%EY",
+    /* <U4EE4><U548C>02<U5E74> 令和02年 */
+    "\xce\xe1\xcf\xc2""02\xc7\xaf" },
 };
 
 #define NDATA array_length(data)