فهرست منبع

The xlsxFont equality checker now properly checks for B/U/I.

Kaur Kuut 10 سال پیش
والد
کامیت
6472b9e71a
2فایلهای تغییر یافته به همراه26 افزوده شده و 2 حذف شده
  1. 9 0
      xmlStyle.go
  2. 17 2
      xmlStyle_test.go

+ 9 - 0
xmlStyle.go

@@ -451,6 +451,15 @@ type xlsxFont struct {
 }
 
 func (font *xlsxFont) Equals(other xlsxFont) bool {
+	if (font.B == nil && other.B != nil) || (font.B != nil && other.B == nil) {
+		return false
+	}
+	if (font.I == nil && other.I != nil) || (font.I != nil && other.I == nil) {
+		return false
+	}
+	if (font.U == nil && other.U != nil) || (font.U != nil && other.U == nil) {
+		return false
+	}
 	return font.Sz.Equals(other.Sz) && font.Name.Equals(other.Name) && font.Family.Equals(other.Family) && font.Charset.Equals(other.Charset) && font.Color.Equals(other.Color)
 }
 

+ 17 - 2
xmlStyle_test.go

@@ -162,11 +162,17 @@ func (x *XMLStyleSuite) TestFontEquals(c *C) {
 	fontA := xlsxFont{Sz: xlsxVal{Val: "11"},
 		Color:  xlsxColor{RGB: "FFFF0000"},
 		Name:   xlsxVal{Val: "Calibri"},
-		Family: xlsxVal{Val: "2"}}
+		Family: xlsxVal{Val: "2"},
+		B:      &struct{}{},
+		I:      &struct{}{},
+		U:      &struct{}{}}
 	fontB := xlsxFont{Sz: xlsxVal{Val: "11"},
 		Color:  xlsxColor{RGB: "FFFF0000"},
 		Name:   xlsxVal{Val: "Calibri"},
-		Family: xlsxVal{Val: "2"}}
+		Family: xlsxVal{Val: "2"},
+		B:      &struct{}{},
+		I:      &struct{}{},
+		U:      &struct{}{}}
 
 	c.Assert(fontA.Equals(fontB), Equals, true)
 	fontB.Sz.Val = "12"
@@ -181,6 +187,15 @@ func (x *XMLStyleSuite) TestFontEquals(c *C) {
 	fontB.Family.Val = "1"
 	c.Assert(fontA.Equals(fontB), Equals, false)
 	fontB.Family.Val = "2"
+	fontB.B = nil
+	c.Assert(fontA.Equals(fontB), Equals, false)
+	fontB.B = &struct{}{}
+	fontB.I = nil
+	c.Assert(fontA.Equals(fontB), Equals, false)
+	fontB.I = &struct{}{}
+	fontB.U = nil
+	c.Assert(fontA.Equals(fontB), Equals, false)
+	fontB.U = &struct{}{}
 	// For sanity
 	c.Assert(fontA.Equals(fontB), Equals, true)
 }