Commit ad02b98b authored by Geoff Simmons's avatar Geoff Simmons

Add RecordType.String.

parent 9f1ee042
...@@ -189,6 +189,8 @@ const ( ...@@ -189,6 +189,8 @@ const (
// it is part of the log for a client request/response, a backend // it is part of the log for a client request/response, a backend
// request/repsonse, or neither. Corresponds to the indicator 'b', // request/repsonse, or neither. Corresponds to the indicator 'b',
// 'c' or '-' in the fourth column of verbose varnishlog output. // 'c' or '-' in the fourth column of verbose varnishlog output.
//
// Use rune(rt) for a RecordType rt to get 'b', 'c' or '-'
type RecordType uint8 type RecordType uint8
const ( const (
...@@ -205,6 +207,11 @@ const ( ...@@ -205,6 +207,11 @@ const (
None = RecordType('-') None = RecordType('-')
) )
// String returns "b", "c" or "-".
func (rt RecordType) String() string {
return string(rt)
}
func initTags() []string { func initTags() []string {
var tags []string var tags []string
if uint8(C.slt_max()) > ^uint8(0) { if uint8(C.slt_max()) > ^uint8(0) {
......
...@@ -91,6 +91,21 @@ func TestReasonString(t *testing.T) { ...@@ -91,6 +91,21 @@ func TestReasonString(t *testing.T) {
} }
} }
var expRecordTypeStr = map[RecordType]string{
Client: "c",
Backend: "b",
None: "-",
}
func TestRecordTypeString(t *testing.T) {
for k, v := range expRecordTypeStr {
if k.String() != v {
t.Errorf("%c.String() expected=%v got=%v", k, v,
k.String())
}
}
}
func TestNewRelease(t *testing.T) { func TestNewRelease(t *testing.T) {
l := New() l := New()
defer l.Release() defer l.Release()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment