2019-07-25 19:43:46 +03:00
|
|
|
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
2017-08-28 20:56:18 -05:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by the terms of the Affero GNU General
|
|
|
|
// Public License version 3.0 as published by the Free Software Foundation and
|
|
|
|
// appearing in the file LICENSE included in the packaging of this file. A
|
Functions2 (#348)
* MATCH, IFS, MAXA, MINA
* OFFSET fixed
* ISBLANK, ISERR, ISERROR, ISEVEN ,ISFORMULA, ISNONTEXT, ISNUMBER, ISODD, ISTEXT
* ISLEAPYEAR, ISLOGICAL, ISNA, ISREF
* FIND, FINDB
* SEARCH, SEARCHB
* CONCAT, CONCATENATE
* YEAR, YEARFRAC
* CONCAT is fixed, now TRUE and FALSE are concatenated instead of 1 and 0 in case of boolean results
* NOW, TODAY, TIME, TIMEVALUE
* DATE
* DATEDIF
2019-11-21 02:21:00 +03:00
|
|
|
// commercial license can be purchased on https://unidoc.io.
|
2017-08-28 20:56:18 -05:00
|
|
|
|
|
|
|
package zippkg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSelfClosing(t *testing.T) {
|
|
|
|
|
|
|
|
td := []struct {
|
|
|
|
Input string
|
|
|
|
Expected string
|
|
|
|
}{
|
2017-08-29 16:55:03 -05:00
|
|
|
{"<test></test>", "<test/>"},
|
2017-08-28 20:56:18 -05:00
|
|
|
{"<test> </test>", "<test> </test>"},
|
2017-08-29 16:55:03 -05:00
|
|
|
{"<test a=\"123\"></test>", "<test a=\"123\"/>"},
|
|
|
|
{`<Default Extension="jpg" ContentType="image/jpg"></Default>`, `<Default Extension="jpg" ContentType="image/jpg"/>`},
|
2017-08-28 20:56:18 -05:00
|
|
|
{`<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" PartName="/xl/styles.xml"></Override>`,
|
2017-08-29 16:55:03 -05:00
|
|
|
`<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" PartName="/xl/styles.xml"/>`},
|
2017-08-28 20:56:18 -05:00
|
|
|
{"<TestStruct><Foo>bar</Foo></TestStruct>", "<TestStruct><Foo>bar</Foo></TestStruct>"},
|
2017-08-29 16:55:03 -05:00
|
|
|
{"<test></test><a></a><b></b>", "<test/><a/><b/>"},
|
2017-08-28 20:56:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range td {
|
|
|
|
buf := bytes.Buffer{}
|
|
|
|
w := SelfClosingWriter{&buf}
|
|
|
|
n, err := w.Write([]byte(tc.Input))
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error writing: %s", err)
|
|
|
|
}
|
|
|
|
if n != len(tc.Input) {
|
|
|
|
t.Errorf("expeced to write %d bytes, wrote %d", len(tc.Input), n)
|
|
|
|
}
|
|
|
|
|
|
|
|
got := buf.String()
|
|
|
|
if got != tc.Expected {
|
|
|
|
t.Errorf("expected write(\"%s\") = \"%s\", got \"%s\"", tc.Input, tc.Expected, got)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|