initrd/colorio/colorio_test.go

22 lines
331 B
Go
Raw Normal View History

package colorio
import (
"bytes"
"fmt"
"testing"
)
func TestWriter(t *testing.T) {
buf := new(bytes.Buffer)
w := NewWriter(Bold, buf)
buf.WriteByte('{')
fmt.Fprintln(w, "hello")
buf.WriteByte('}')
if s, exp := buf.String(), "{"+string(Bold)+"hello\n"+string(Reset)+"}"; s != exp {
t.Errorf("%q != %q", s, exp)
}
}