summaryrefslogtreecommitdiff
path: root/docProps_test.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2019-12-22 00:02:09 +0800
committerxuri <xuri.me@gmail.com>2019-12-22 00:02:09 +0800
commitae2865d9237cfd27d7bc4fbef3870b3361597be8 (patch)
tree175964d3757a0da1bf84c5ff495636baf237b681 /docProps_test.go
parent7358dca436f6ca5948a3f2865b14e828863d86a9 (diff)
Improve code coverage unit tests
Diffstat (limited to 'docProps_test.go')
-rw-r--r--docProps_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/docProps_test.go b/docProps_test.go
index df3122b..30c3149 100644
--- a/docProps_test.go
+++ b/docProps_test.go
@@ -16,6 +16,8 @@ import (
"github.com/stretchr/testify/assert"
)
+var MacintoshCyrillicCharset = []byte{0x8F, 0xF0, 0xE8, 0xE2, 0xE5, 0xF2, 0x20, 0xEC, 0xE8, 0xF0}
+
func TestSetDocProps(t *testing.T) {
f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
if !assert.NoError(t, err) {
@@ -40,6 +42,11 @@ func TestSetDocProps(t *testing.T) {
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetDocProps.xlsx")))
f.XLSX["docProps/core.xml"] = nil
assert.NoError(t, f.SetDocProps(&DocProperties{}))
+
+ // Test unsupport charset
+ f = NewFile()
+ f.XLSX["docProps/core.xml"] = MacintoshCyrillicCharset
+ assert.EqualError(t, f.SetDocProps(&DocProperties{}), "xml decode error: XML syntax error on line 1: invalid UTF-8")
}
func TestGetDocProps(t *testing.T) {
@@ -53,4 +60,10 @@ func TestGetDocProps(t *testing.T) {
f.XLSX["docProps/core.xml"] = nil
_, err = f.GetDocProps()
assert.NoError(t, err)
+
+ // Test unsupport charset
+ f = NewFile()
+ f.XLSX["docProps/core.xml"] = MacintoshCyrillicCharset
+ _, err = f.GetDocProps()
+ assert.EqualError(t, err, "xml decode error: XML syntax error on line 1: invalid UTF-8")
}