blob: 288976ab4bb2a2f7a3154a15a5906c230f1f54bc (
plain) (
blame)
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
|
package proto
import (
"reflect"
"testing"
"github.com/ClickHouse/ch-go/internal/gold"
)
func typeName(v interface{}) string {
t := reflect.TypeOf(v)
if t.Kind() == reflect.Ptr {
return t.Elem().Name()
}
return t.Name()
}
// Gold checks golden version of v encoding.
func Gold(t testing.TB, v AwareEncoder, name ...string) {
t.Helper()
if len(name) == 0 {
name = []string{"type", typeName(v)}
}
var b Buffer
v.EncodeAware(&b, Version)
gold.Bytes(t, b.Buf, name...)
}
|