ipld-eth-server/vendor/github.com/opentracing/opentracing-go/log/field_test.go

40 lines
645 B
Go
Raw Normal View History

package log
import (
"fmt"
"testing"
)
func TestFieldString(t *testing.T) {
testCases := []struct {
field Field
expected string
}{
{
field: String("key", "value"),
expected: "key:value",
},
{
field: Bool("key", true),
expected: "key:true",
},
{
field: Int("key", 5),
expected: "key:5",
},
{
field: Error(fmt.Errorf("err msg")),
expected: "error:err msg",
},
{
field: Error(nil),
expected: "error:<nil>",
},
}
for i, tc := range testCases {
if str := tc.field.String(); str != tc.expected {
t.Errorf("%d: expected '%s', got '%s'", i, tc.expected, str)
}
}
}