1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package pp
import (
"bytes"
"testing"
)
func TestDefaultOutput(t *testing.T) {
testOutput := new(bytes.Buffer)
init := GetDefaultOutput()
SetDefaultOutput(testOutput)
if GetDefaultOutput() != testOutput {
t.Errorf("failed to SetDefaultOutput")
}
if len(testOutput.String()) != 0 {
t.Errorf("testOutput should be initialized")
}
Print("abcde")
if len(testOutput.String()) == 0 {
t.Errorf("Expected Print output to testOutput, testOutput is %s", testOutput.String())
}
if init == GetDefaultOutput() {
t.Errorf("it should be changed DefaultOutput")
}
ResetDefaultOutput()
if init != GetDefaultOutput() {
t.Errorf("it should be reset to initial default output")
}
}
func TestColorScheme(t *testing.T) {
SetColorScheme(ColorScheme{})
if currentScheme.FieldName == 0 {
t.FailNow()
}
}
|