@@ -62,31 +62,57 @@ func TestXlsxMergedCellErrors(t *testing.T) {
6262 }
6363}
6464
65- // Spec 077 "Typing": Japanese text under a pinned type reads as its ASCII
66- // form, a yen amount, a kanji date, or an era date ; text that is none of
67- // these still fails the type, quoted as the cell holds it.
65+ // Spec 077 "Japanese text under a pinned type": every family of amount,
66+ // date, time, and yes/no form reads under its pinned type ; text outside
67+ // the forms fails the type, quoted as the cell holds it.
6868func TestXlsxTypesJapanese (t * testing.T ) {
6969 t .Parallel ()
7070 dagu := harness .NewRunner (t )
7171 dagu .Run ("start" , "types_japanese.yaml" ).ExpectExitCode (0 )
7272
73- var rows []map [string ]any
74- readJSON (t , dagu , "out.json" , & rows )
75- require .Len (t , rows , 4 )
76- require .Equal (t , float64 (123456 ), rows [0 ]["Amount" ], "full-width digits and comma" )
77- require .Equal (t , "2026-10-03" , rows [0 ]["Due" ], "full-width slashes" )
78- require .Equal (t , "007" , rows [0 ]["Code" ], "an unpinned column keeps its text" )
79- require .Equal (t , float64 (123000 ), rows [1 ]["Amount" ], "a yen sign before the amount" )
80- require .Equal (t , "2026-10-03" , rows [1 ]["Due" ], "an era date, long" )
81- require .Equal (t , float64 (123000 ), rows [2 ]["Amount" ], "円 after the amount" )
82- require .Equal (t , "2026-10-03" , rows [2 ]["Due" ], "an era date, short" )
83- require .Equal (t , float64 (- 5 ), rows [3 ]["Amount" ], "the minus sign U+2212" )
84- require .Equal (t , "2019-05-01" , rows [3 ]["Due" ], "the first year of an era" )
73+ var out struct {
74+ Rows []map [string ]any `json:"rows"`
75+ Warnings []string `json:"warnings"`
76+ }
77+ readJSON (t , dagu , "out.json" , & out )
78+ require .Len (t , out .Rows , 14 )
79+ for i , want := range []struct {
80+ amount float64
81+ due string
82+ when string
83+ done any
84+ note string
85+ }{
86+ {123456 , "2026-10-03" , "2026-10-03T14:30:00" , true , "full-width digits; a slash date with a time; a circle" },
87+ {123000 , "2026-10-03" , "2026-10-03T14:30:00" , false , "a yen sign; an era date; 時分; a cross" },
88+ {123000 , "2026-10-03" , "2026-10-03T14:30:15" , true , "円 after; a short era date; 時分秒; はい" },
89+ {- 5 , "2019-05-01" , "2026-10-03T14:30:15" , false , "U+2212; the first year of an era; a dot date with seconds; いいえ" },
90+ {123500 , "2026-10-03" , "2026-10-03T14:30:00" , true , "Arabic digits with 万; a weekday mark; 午後; 済" },
91+ {- 1000 , "2026-10-01" , "2026-10-03T14:00:00" , false , "▲; an era month; 時 alone; 未" },
92+ {- 1000 , "2026-10-01" , "2026-10-03T09:00:00" , false , "accounting parentheses; a kanji month; 午前; 無" },
93+ {123000 , "2026-10-03" , "2026-10-03T14:30:00" , nil , "the trailing dash; kanji digits in place; (Fri); △ is not a boolean" },
94+ {10 , "2026-10-03" , "2026-10-03T14:30:00" , false , "percent; an era ligature; a weekday before the time; a dash for none" },
95+ {123000 , "2019-04-30" , "2026-10-03T12:00:00" , false , "a receipt in daiji; kanji numerals with units; 午後0時; an empty box" },
96+ {1000 , "2026-10-03" , "2026-10-03T00:00:00" , true , "a price tag; a dot date; 午前12時; 有" },
97+ {150000000 , "2019-04-30" , "2026-10-03T00:00:00" , true , "億; a dashed era date; a date alone; a check mark" },
98+ {1000 , "2026-10-03" , "2026-10-03T14:30:00" , false , "a tag in parentheses; a kanji era date; a colon time; 不要" },
99+ {1000000 , "2026-10-01" , "2026-10-03T14:00:00" , true , "百万; a slash month; 金曜日 before the time; 完了" },
100+ } {
101+ row := out .Rows [i ]
102+ require .Equal (t , want .amount , row ["Amount" ], "row %d amount: %s" , i + 2 , want .note )
103+ require .Equal (t , want .due , row ["Due" ], "row %d due: %s" , i + 2 , want .note )
104+ require .Equal (t , want .when , row ["When" ], "row %d when: %s" , i + 2 , want .note )
105+ require .Equal (t , want .done , row ["Done" ], "row %d done: %s" , i + 2 , want .note )
106+ }
107+ require .Equal (t , "007" , out .Rows [0 ]["Code" ], "an unpinned column keeps its text" )
108+ require .Equal (t , []string {`Sheet1!D9: expected boolean, found "△"` }, out .Warnings )
85109
86110 var warnings []string
87111 readJSON (t , dagu , "warnings.json" , & warnings )
88112 require .Equal (t , []string {
89- `Sheet1!C4: expected number, found "abc"` ,
90- `Sheet1!C5: expected number, found "x"` ,
91- }, warnings , "full-width digits pinned to number convert; other text is quoted as it is" )
113+ `Sheet1!E4: expected number, found "abc"` ,
114+ `Sheet1!E5: expected number, found "1,000(千円)"` ,
115+ `Sheet1!E6: expected number, found "12万3万"` ,
116+ `Sheet1!D9: expected boolean, found "△"` ,
117+ }, warnings , "text outside the forms is quoted as the cell holds it" )
92118}
0 commit comments