MCPcopy
hub / github.com/etcd-io/bbolt / TestTxidSorting

Function TestTxidSorting

internal/freelist/freelist_test.go:277–298  ·  view source on GitHub ↗

Ensure that the txIDx swap, less and len are properly implemented

(t *testing.T)

Source from the content-addressed store, hash-verified

275
276// Ensure that the txIDx swap, less and len are properly implemented
277func TestTxidSorting(t *testing.T) {
278 require.NoError(t, quick.Check(func(a []uint64) bool {
279 var txids []common.Txid
280 for _, txid := range a {
281 txids = append(txids, common.Txid(txid))
282 }
283
284 sort.Sort(txIDx(txids))
285
286 var r []uint64
287 for _, txid := range txids {
288 r = append(r, uint64(txid))
289 }
290
291 if !slices.IsSorted(r) {
292 t.Errorf("txids were not sorted correctly=%v", txids)
293 return false
294 }
295
296 return true
297 }, nil))
298}
299
300// Ensure that a freelist can deserialize from a freelist page.
301func TestFreelist_read(t *testing.T) {

Callers

nothing calls this directly

Calls 4

TxidTypeAlias · 0.92
txIDxTypeAlias · 0.85
CheckMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected