tile38/controller/log/log_test.go

27 lines
386 B
Go
Raw Normal View History

2016-07-12 19:07:28 +03:00
package log
import (
"bytes"
2017-10-03 18:49:33 +03:00
"io/ioutil"
2016-07-12 19:07:28 +03:00
"strings"
"testing"
)
func TestLog(t *testing.T) {
f := &bytes.Buffer{}
2017-10-03 18:49:33 +03:00
SetOutput(f)
2016-07-12 19:07:28 +03:00
Printf("hello %v", "everyone")
if !strings.HasSuffix(f.String(), "hello everyone\n") {
t.Fatal("fail")
}
}
2017-10-03 18:49:33 +03:00
func BenchmarkLogPrintf(t *testing.B) {
SetOutput(ioutil.Discard)
t.ResetTimer()
for i := 0; i < t.N; i++ {
Printf("X %s", "Y")
}
}