MCPcopy Create free account
hub / github.com/couchbase/moss / TestBatchSort

Function TestBatchSort

collection_test.go:206–290  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

204}
205
206func TestBatchSort(t *testing.T) {
207 m, _ := NewCollection(CollectionOptions{})
208
209 segbatch, err := m.NewBatch(0, 0)
210 if err != nil {
211 t.Errorf("expected ok")
212 }
213
214 b := segbatch.(*batch)
215
216 b.Set([]byte("f"), []byte("F"))
217 b.Set([]byte("d"), []byte("D"))
218 b.Set([]byte("b"), []byte("B"))
219
220 o, k, v := b.getOperationKeyVal(0)
221 if o != OperationSet || string(k) != "f" || string(v) != "F" {
222 t.Errorf("wrong okv")
223 }
224 o, k, v = b.getOperationKeyVal(1)
225 if o != OperationSet || string(k) != "d" || string(v) != "D" {
226 t.Errorf("wrong okv")
227 }
228 o, k, v = b.getOperationKeyVal(2)
229 if o != OperationSet || string(k) != "b" || string(v) != "B" {
230 t.Errorf("wrong okv")
231 }
232
233 sort.Sort(b)
234
235 b2 := b
236
237 o, k, v = b2.getOperationKeyVal(0)
238 if o != OperationSet || string(k) != "b" || string(v) != "B" {
239 t.Errorf("wrong okv")
240 }
241 o, k, v = b2.getOperationKeyVal(1)
242 if o != OperationSet || string(k) != "d" || string(v) != "D" {
243 t.Errorf("wrong okv")
244 }
245 o, k, v = b2.getOperationKeyVal(2)
246 if o != OperationSet || string(k) != "f" || string(v) != "F" {
247 t.Errorf("wrong okv")
248 }
249 o, k, v = b2.getOperationKeyVal(3)
250 if o != 0 || k != nil || v != nil {
251 t.Errorf("wrong okv")
252 }
253
254 i := b2.findStartKeyInclusivePos(nil)
255 if i != 0 {
256 t.Errorf("wrong i")
257 }
258 i = b2.findStartKeyInclusivePos([]byte(""))
259 if i != 0 {
260 t.Errorf("wrong i")
261 }
262 i = b2.findStartKeyInclusivePos([]byte("a"))
263 if i != 0 {

Callers

nothing calls this directly

Calls 5

NewBatchMethod · 0.95
NewCollectionFunction · 0.85
getOperationKeyValMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…