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

Function TestByteViewSlice

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

Source from the content-addressed store, hash-verified

101}
102
103func TestByteViewSlice(t *testing.T) {
104 tests := []struct {
105 in string
106 from int
107 to interface{} // nil to mean the end (SliceFrom); else int
108 want string
109 }{
110 {
111 in: "abc",
112 from: 1,
113 to: 2,
114 want: "b",
115 },
116 {
117 in: "abc",
118 from: 1,
119 want: "bc",
120 },
121 {
122 in: "abc",
123 to: 2,
124 want: "ab",
125 },
126 }
127 for i, tt := range tests {
128 for _, v := range []ByteView{of([]byte(tt.in)), of(tt.in)} {
129 name := fmt.Sprintf("test %d, view %+v", i, v)
130 if tt.to != nil {
131 v = v.Slice(tt.from, tt.to.(int))
132 } else {
133 v = v.SliceFrom(tt.from)
134 }
135 if v.String() != tt.want {
136 t.Errorf("%s: got %q; want %q", name, v.String(), tt.want)
137 }
138 }
139 }
140}
141
142func min(a, b int) int {
143 if a < b {

Callers

nothing calls this directly

Calls 4

ofFunction · 0.85
SliceMethod · 0.80
SliceFromMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…