summaryrefslogtreecommitdiff
path: root/picture_test.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2022-11-13 00:40:04 +0800
committerxuri <xuri.me@gmail.com>2022-11-13 00:40:04 +0800
commitac564afa56a691e378ab9bb04cb14bb283886a16 (patch)
treedef0303fd88e78897a3c739c31c89cff8f492d43 /picture_test.go
parentbd5dd17673f767b9f4643423c77eec486f2ad53f (diff)
Remove internal error log print, throw XML deserialize error
Diffstat (limited to 'picture_test.go')
-rw-r--r--picture_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/picture_test.go b/picture_test.go
index 65abf9e..11196c6 100644
--- a/picture_test.go
+++ b/picture_test.go
@@ -67,6 +67,12 @@ func TestAddPicture(t *testing.T) {
// Test write file to given path.
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture1.xlsx")))
assert.NoError(t, f.Close())
+
+ // Test add picture with unsupported charset content types.
+ f = NewFile()
+ f.ContentTypes = nil
+ f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset)
+ assert.EqualError(t, f.AddPictureFromBytes("Sheet1", "Q1", "", "Excel Logo", ".png", file), "XML syntax error on line 1: invalid UTF-8")
}
func TestAddPictureErrors(t *testing.T) {
@@ -236,3 +242,27 @@ func TestDrawingResize(t *testing.T) {
ws.(*xlsxWorksheet).MergeCells = &xlsxMergeCells{Cells: []*xlsxMergeCell{{Ref: "A:A"}}}
assert.EqualError(t, f.AddPicture("Sheet1", "A1", filepath.Join("test", "images", "excel.jpg"), `{"autofit": true}`), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
}
+
+func TestSetContentTypePartImageExtensions(t *testing.T) {
+ f := NewFile()
+ // Test set content type part image extensions with unsupported charset content types.
+ f.ContentTypes = nil
+ f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset)
+ assert.EqualError(t, f.setContentTypePartImageExtensions(), "XML syntax error on line 1: invalid UTF-8")
+}
+
+func TestSetContentTypePartVMLExtensions(t *testing.T) {
+ f := NewFile()
+ // Test set content type part VML extensions with unsupported charset content types.
+ f.ContentTypes = nil
+ f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset)
+ assert.EqualError(t, f.setContentTypePartVMLExtensions(), "XML syntax error on line 1: invalid UTF-8")
+}
+
+func TestAddContentTypePart(t *testing.T) {
+ f := NewFile()
+ // Test add content type part with unsupported charset content types.
+ f.ContentTypes = nil
+ f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset)
+ assert.EqualError(t, f.addContentTypePart(0, "unknown"), "XML syntax error on line 1: invalid UTF-8")
+}