@@ -301,7 +301,7 @@ func TestSetCellRichText(t *testing.T) {
301301 assert .EqualError (t , f .SetCellRichText ("Sheet1" , "A" , richTextRun ), `cannot convert cell "A" to coordinates: invalid cell name "A"` )
302302}
303303
304- func TestFormattedValue (t * testing.T ) {
304+ func TestFormattedValue2 (t * testing.T ) {
305305 f := NewFile ()
306306 v := f .formattedValue (0 , "43528" )
307307 assert .Equal (t , "43528" , v )
@@ -320,12 +320,24 @@ func TestFormattedValue(t *testing.T) {
320320 assert .Equal (t , "03/04/2019" , v )
321321
322322 // formatted value with no built-in number format ID
323- assert .NoError (t , err )
324- f .Styles .NumFmts = nil
325323 numFmtID := 5
326324 f .Styles .CellXfs .Xf = append (f .Styles .CellXfs .Xf , xlsxXf {
327325 NumFmtID : & numFmtID ,
328326 })
327+ v = f .formattedValue (2 , "43528" )
328+ assert .Equal (t , "43528" , v )
329+
330+ // formatted value with invalid number format ID
331+ f .Styles .CellXfs .Xf = append (f .Styles .CellXfs .Xf , xlsxXf {
332+ NumFmtID : nil ,
333+ })
334+ v = f .formattedValue (3 , "43528" )
335+
336+ // formatted value with empty number format
337+ f .Styles .NumFmts = nil
338+ f .Styles .CellXfs .Xf = append (f .Styles .CellXfs .Xf , xlsxXf {
339+ NumFmtID : & numFmtID ,
340+ })
329341 v = f .formattedValue (1 , "43528" )
330342 assert .Equal (t , "43528" , v )
331343}
0 commit comments