@@ -32,13 +32,22 @@ func TestOpenFile(t *testing.T) {
32
32
assert .EqualError (t , err , "sheet Sheet4 does not exist" )
33
33
// Test get all the rows in a worksheet.
34
34
rows , err := f .GetRows ("Sheet2" )
35
- assert .NoError (t , err )
36
- for _ , row := range rows {
37
- for _ , cell := range row {
38
- t .Log (cell , "\t " )
39
- }
40
- t .Log ("\r \n " )
35
+ expected := [][]string {
36
+ {"Monitor" , "" , "Brand" , "" , "inlineStr" },
37
+ {"> 23 Inch" , "19" , "HP" , "200" },
38
+ {"20-23 Inch" , "24" , "DELL" , "450" },
39
+ {"17-20 Inch" , "56" , "Lenove" , "200" },
40
+ {"< 17 Inch" , "21" , "SONY" , "510" },
41
+ {"" , "" , "Acer" , "315" },
42
+ {"" , "" , "IBM" , "127" },
43
+ {"" , "" , "ASUS" , "89" },
44
+ {"" , "" , "Apple" , "348" },
45
+ {"" , "" , "SAMSUNG" , "53" },
46
+ {"" , "" , "Other" , "37" , "" , "" , "" , "" , "" },
41
47
}
48
+ assert .NoError (t , err )
49
+ assert .Equal (t , expected , rows )
50
+
42
51
assert .NoError (t , f .UpdateLinkedValue ())
43
52
44
53
assert .NoError (t , f .SetCellDefault ("Sheet2" , "A1" , strconv .FormatFloat (100.1588 , 'f' , - 1 , 32 )))
@@ -396,13 +405,19 @@ func TestGetCellHyperLink(t *testing.T) {
396
405
397
406
link , target , err := f .GetCellHyperLink ("Sheet1" , "A22" )
398
407
assert .NoError (t , err )
399
- t .Log (link , target )
408
+ assert .Equal (t , link , true )
409
+ assert .Equal (t , target , "https://github.com/xuri/excelize" )
410
+
400
411
link , target , err = f .GetCellHyperLink ("Sheet2" , "D6" )
401
412
assert .NoError (t , err )
402
- t .Log (link , target )
413
+ assert .Equal (t , link , false )
414
+ assert .Equal (t , target , "" )
415
+
403
416
link , target , err = f .GetCellHyperLink ("Sheet3" , "H3" )
404
417
assert .EqualError (t , err , "sheet Sheet3 does not exist" )
405
- t .Log (link , target )
418
+ assert .Equal (t , link , false )
419
+ assert .Equal (t , target , "" )
420
+
406
421
assert .NoError (t , f .Close ())
407
422
408
423
f = NewFile ()
@@ -709,6 +724,14 @@ func TestSetCellStyleNumberFormat(t *testing.T) {
709
724
col := []string {"L" , "M" , "N" , "O" , "P" }
710
725
data := []int {0 , 1 , 2 , 3 , 4 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 }
711
726
value := []string {"37947.7500001" , "-37947.7500001" , "0.007" , "2.1" , "String" }
727
+ expected := [][]string {
728
+ {"37947.7500001" , "37948" , "37947.75" , "37948" , "37947.75" , "3794775%" , "3794775.00%" , "3.79E+04" , "37947.7500001" , "37947.7500001" , "11-22-03" , "22-Nov-03" , "22-Nov" , "Nov-03" , "6:00 pm" , "6:00:00 pm" , "18:00" , "18:00:00" , "11/22/03 18:00" , "37947" , "37947" , "37947.75" , "37947.75" , "37947.7500001" , "37947.7500001" , "37947.7500001" , "37947.7500001" , "00:00" , "910746:00:00" , "37947.7500001" , "3.79E+04" , "37947.7500001" },
729
+ {"-37947.7500001" , "-37948" , "-37947.75" , "-37948" , "-37947.75" , "-3794775%" , "-3794775.00%" , "-3.79E+04" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "(37947)" , "(37947)" , "(-37947.75)" , "(-37947.75)" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-37947.7500001" , "-3.79E+04" , "-37947.7500001" },
730
+ {"0.007" , "0" , "0.01" , "0" , "0.01" , "1%" , "0.70%" , "7.00E-03" , "0.007" , "0.007" , "12-30-99" , "30-Dec-99" , "30-Dec" , "Dec-99" , "0:10 am" , "0:10:04 am" , "00:10" , "00:10:04" , "12/30/99 00:10" , "0" , "0" , "0.01" , "0.01" , "0.007" , "0.007" , "0.007" , "0.007" , "10:04" , "0:10:04" , "0.007" , "7.00E-03" , "0.007" },
731
+ {"2.1" , "2" , "2.10" , "2" , "2.10" , "210%" , "210.00%" , "2.10E+00" , "2.1" , "2.1" , "01-01-00" , "1-Jan-00" , "1-Jan" , "Jan-00" , "2:24 am" , "2:24:00 am" , "02:24" , "02:24:00" , "1/1/00 02:24" , "2" , "2" , "2.10" , "2.10" , "2.1" , "2.1" , "2.1" , "2.1" , "24:00" , "50:24:00" , "2.1" , "2.10E+00" , "2.1" },
732
+ {"String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" , "String" },
733
+ }
734
+
712
735
for i , v := range value {
713
736
for k , d := range data {
714
737
c := col [i ] + strconv .Itoa (k + 1 )
@@ -724,7 +747,9 @@ func TestSetCellStyleNumberFormat(t *testing.T) {
724
747
t .FailNow ()
725
748
}
726
749
assert .NoError (t , f .SetCellStyle ("Sheet2" , c , c , style ))
727
- t .Log (f .GetCellValue ("Sheet2" , c ))
750
+ cellValue , err := f .GetCellValue ("Sheet2" , c )
751
+ assert .Equal (t , expected [i ][k ], cellValue )
752
+ assert .NoError (t , err )
728
753
}
729
754
}
730
755
var style int
0 commit comments