diff options
author | xuri <xuri.me@gmail.com> | 2022-11-12 00:02:11 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2022-11-12 00:16:23 +0800 |
commit | bd5dd17673f767b9f4643423c77eec486f2ad53f (patch) | |
tree | d1ceaf5f7eeff101bcf5b3f9a861a8b115088718 /drawing_test.go | |
parent | 58b5dae5eb4948a3cde238ced1ae05db159749f5 (diff) |
This is a breaking change, remove partial internal error log print, throw XML deserialize error
- Add error return value for the `GetComments`, `GetDefaultFont` and `SetDefaultFont` functions
- Update unit tests
Diffstat (limited to 'drawing_test.go')
-rw-r--r-- | drawing_test.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drawing_test.go b/drawing_test.go index e37b771..5c090eb 100644 --- a/drawing_test.go +++ b/drawing_test.go @@ -15,6 +15,8 @@ import ( "encoding/xml" "sync" "testing" + + "github.com/stretchr/testify/assert" ) func TestDrawingParser(t *testing.T) { @@ -24,12 +26,15 @@ func TestDrawingParser(t *testing.T) { } f.Pkg.Store("charset", MacintoshCyrillicCharset) f.Pkg.Store("wsDr", []byte(xml.Header+`<xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"><xdr:oneCellAnchor><xdr:graphicFrame/></xdr:oneCellAnchor></xdr:wsDr>`)) - // Test with one cell anchor - f.drawingParser("wsDr") - // Test with unsupported charset - f.drawingParser("charset") - // Test with alternate content + // Test with one cell anchor. + _, _, err := f.drawingParser("wsDr") + assert.NoError(t, err) + // Test with unsupported charset. + _, _, err = f.drawingParser("charset") + assert.EqualError(t, err, "XML syntax error on line 1: invalid UTF-8") + // Test with alternate content. f.Drawings = sync.Map{} f.Pkg.Store("wsDr", []byte(xml.Header+`<xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"><mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"><mc:Choice xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" Requires="a14"><xdr:twoCellAnchor editAs="oneCell"></xdr:twoCellAnchor></mc:Choice><mc:Fallback/></mc:AlternateContent></xdr:wsDr>`)) - f.drawingParser("wsDr") + _, _, err = f.drawingParser("wsDr") + assert.NoError(t, err) } |