tile38/internal/log/log_test.go

27 lines
386 B
Go
Raw Normal View History

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