// Copyright 2017 Baliance. All rights reserved.
//
// 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
// commercial license can be purchased by contacting sales@baliance.com.
package zippkg
import (
"bytes"
"testing"
)
func TestSelfClosing(t *testing.T) {
td := []struct {
Input string
Expected string
}{
{"", ""},
{" ", " "},
{"", ""},
{``, ``},
{``,
``},
{"bar", "bar"},
{"", ""},
}
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)
}
}
}