diff options
Diffstat (limited to 'docProps_test.go')
-rw-r--r-- | docProps_test.go | 13 |
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") } |