MCPcopy
hub / github.com/segmentio/ksuid / testCompressedSetSparse

Function testCompressedSetSparse

set_test.go:84–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func testCompressedSetSparse(t *testing.T) {
85 now := time.Now()
86
87 times := [100]time.Time{}
88 for i := range times {
89 times[i] = now.Add(time.Duration(i) * 2 * time.Second)
90 }
91
92 ksuids := [1000]KSUID{}
93 for i := range ksuids {
94 ksuids[i], _ = NewRandomWithTime(times[i%len(times)])
95 }
96
97 set := Compress(ksuids[:]...)
98
99 for i, it := 0, set.Iter(); it.Next(); {
100 if i >= len(ksuids) {
101 t.Error("too many KSUIDs were produced by the set iterator")
102 break
103 }
104 if ksuids[i] != it.KSUID {
105 t.Errorf("bad KSUID at index %d: expected %s but found %s", i, ksuids[i], it.KSUID)
106 }
107 i++
108 }
109
110 reportCompressionRatio(t, ksuids[:], set)
111}
112
113func testCompressedSetPacked(t *testing.T) {
114 sequences := [10]Sequence{}

Callers

nothing calls this directly

Calls 5

NewRandomWithTimeFunction · 0.85
CompressFunction · 0.85
reportCompressionRatioFunction · 0.85
IterMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…