Просмотр исходного кода

Convert TestGetStyleWithFonts.

Geoffrey J. Teale 11 лет назад
Родитель
Сommit
db25a85193
1 измененных файлов с 24 добавлено и 30 удалено
  1. 24 30
      lib_test.go

+ 24 - 30
lib_test.go

@@ -47,36 +47,30 @@ func (l *LibSuite) TestCreateSheet(c *C) {
 	c.Assert(cellstring, Equals, "Foo")
 }
 
-// // Test that GetStyle correctly converts the xlsxStyle.Fonts.
-// func (l *LibSuite) TestGetStyleWithFonts(c *C) {
-// 	var cell *Cell
-// 	var style *Style
-// 	var xStyles *xlsxStyles
-// 	var fonts []xlsxFont
-// 	var cellXfs []xlsxXf
-
-// 	fonts = make([]xlsxFont, 1)
-// 	fonts[0] = xlsxFont{
-// 		Sz:   xlsxVal{Val: "10"},
-// 		Name: xlsxVal{Val: "Calibra"}}
-
-// 	cellXfs = make([]xlsxXf, 1)
-// 	cellXfs[0] = xlsxXf{ApplyFont: true, FontId: 0}
-
-// 	xStyles = &xlsxStyles{Fonts: fonts, CellXfs: cellXfs}
-
-// 	cell = &Cell{Value: "123", styleIndex: 1, styles: xStyles}
-// 	style = cell.GetStyle()
-// 	if style == nil {
-// 		t.Error("No style returned by cell.GetStyle()")
-// 	}
-// 	if style.Font.Size != 10 {
-// 		t.Error("Expected style.Font.Size == 10, but got ", style.Font.Size)
-// 	}
-// 	if style.Font.Name != "Calibra" {
-// 		t.Error("Expected style.Font.Name == 'Calibra', but got ", style.Font.Name)
-// 	}
-// }
+// Test that GetStyle correctly converts the xlsxStyle.Fonts.
+func (l *LibSuite) TestGetStyleWithFonts(c *C) {
+	var cell *Cell
+	var style *Style
+	var xStyles *xlsxStyles
+	var fonts []xlsxFont
+	var cellXfs []xlsxXf
+
+	fonts = make([]xlsxFont, 1)
+	fonts[0] = xlsxFont{
+		Sz:   xlsxVal{Val: "10"},
+		Name: xlsxVal{Val: "Calibra"}}
+
+	cellXfs = make([]xlsxXf, 1)
+	cellXfs[0] = xlsxXf{ApplyFont: true, FontId: 0}
+
+	xStyles = &xlsxStyles{Fonts: fonts, CellXfs: cellXfs}
+
+	cell = &Cell{Value: "123", styleIndex: 1, styles: xStyles}
+	style = cell.GetStyle()
+	c.Assert(style, NotNil)
+	c.Assert(style.Font.Size, Equals, 10)
+	c.Assert(style.Font.Name, Equals, "Calibra")
+}
 
 // // Test that GetStyle correctly converts the xlsxStyle.Fills.
 // func (l *LibSuite) TestGetStyleWithFills(c *C) {