|
|
@@ -37,6 +37,30 @@ func TestExtractSheets(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+func TestMakeSharedStringRefTable(t *testing.T) {
|
|
|
+ var sharedstringsXML = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
|
+<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="4" uniqueCount="4"><si><t>Foo</t></si><si><t>Bar</t></si><si><t xml:space="preserve">Baz </t></si><si><t>Quuk</t></si></sst>`)
|
|
|
+ sst := new(XLSXSST)
|
|
|
+ error := xml.Unmarshal(sharedstringsXML, sst)
|
|
|
+ if error != nil {
|
|
|
+ t.Error(error.String())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reftable := MakeSharedStringRefTable(sst)
|
|
|
+ if len(reftable) == 0 {
|
|
|
+ t.Error("Reftable is zero length.")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if reftable[0] != "Foo" {
|
|
|
+ t.Error("RefTable lookup failed, expected reftable[0] == 'Foo'")
|
|
|
+ }
|
|
|
+ if reftable[1] != "Bar" {
|
|
|
+ t.Error("RefTable lookup failed, expected reftable[1] == 'Bar'")
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
func TestUnmarshallSharedStrings(t *testing.T) {
|
|
|
var sharedstringsXML = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
|
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="4" uniqueCount="4"><si><t>Foo</t></si><si><t>Bar</t></si><si><t xml:space="preserve">Baz </t></si><si><t>Quuk</t></si></sst>`)
|
|
|
@@ -123,6 +147,8 @@ func TestUnmarshallSheet(t *testing.T) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
func TestUnmarshallXML(t *testing.T) {
|
|
|
var error os.Error
|
|
|
var buf = bytes.NewBufferString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild="4506"/><workbookPr defaultThemeVersion="124226"/><bookViews><workbookView xWindow="120" yWindow="75" windowWidth="15135" windowHeight="7620"/></bookViews><sheets><sheet name="Sheet1" sheetId="1" r:id="rId1"/><sheet name="Sheet2" sheetId="2" r:id="rId2"/><sheet name="Sheet3" sheetId="3" r:id="rId3"/></sheets><definedNames><definedName name="monitors" localSheetId="0">Sheet1!$A$1533</definedName></definedNames><calcPr calcId="125725"/></workbook>`)
|