MCPcopy Index your code
hub / github.com/golang/groupcache / TestByteViewEqual

Function TestByteViewEqual

byteview_test.go:67–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestByteViewEqual(t *testing.T) {
68 tests := []struct {
69 a interface{} // string or []byte
70 b interface{} // string or []byte
71 want bool
72 }{
73 {"x", "x", true},
74 {"x", "y", false},
75 {"x", "yy", false},
76 {[]byte("x"), []byte("x"), true},
77 {[]byte("x"), []byte("y"), false},
78 {[]byte("x"), []byte("yy"), false},
79 {[]byte("x"), "x", true},
80 {[]byte("x"), "y", false},
81 {[]byte("x"), "yy", false},
82 {"x", []byte("x"), true},
83 {"x", []byte("y"), false},
84 {"x", []byte("yy"), false},
85 }
86 for i, tt := range tests {
87 va := of(tt.a)
88 if bytes, ok := tt.b.([]byte); ok {
89 if got := va.EqualBytes(bytes); got != tt.want {
90 t.Errorf("%d. EqualBytes = %v; want %v", i, got, tt.want)
91 }
92 } else {
93 if got := va.EqualString(tt.b.(string)); got != tt.want {
94 t.Errorf("%d. EqualString = %v; want %v", i, got, tt.want)
95 }
96 }
97 if got := va.Equal(of(tt.b)); got != tt.want {
98 t.Errorf("%d. Equal = %v; want %v", i, got, tt.want)
99 }
100 }
101}
102
103func TestByteViewSlice(t *testing.T) {
104 tests := []struct {

Callers

nothing calls this directly

Calls 4

ofFunction · 0.85
EqualBytesMethod · 0.80
EqualStringMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…