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

Function testCompressedSetMixed

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

Source from the content-addressed store, hash-verified

138}
139
140func testCompressedSetMixed(t *testing.T) {
141 now := time.Now()
142
143 times := [20]time.Time{}
144 for i := range times {
145 times[i] = now.Add(time.Duration(i) * 2 * time.Second)
146 }
147
148 sequences := [200]Sequence{}
149 for i := range sequences {
150 seed, _ := NewRandomWithTime(times[i%len(times)])
151 sequences[i] = Sequence{Seed: seed}
152 }
153
154 ksuids := [1000]KSUID{}
155 for i := range ksuids {
156 ksuids[i], _ = sequences[i%len(sequences)].Next()
157 }
158
159 set := Compress(ksuids[:]...)
160
161 for i, it := 0, set.Iter(); it.Next(); {
162 if i >= len(ksuids) {
163 t.Error("too many KSUIDs were produced by the set iterator")
164 break
165 }
166 if ksuids[i] != it.KSUID {
167 t.Errorf("bad KSUID at index %d: expected %s but found %s", i, ksuids[i], it.KSUID)
168 }
169 i++
170 }
171
172 reportCompressionRatio(t, ksuids[:], set)
173}
174
175func testCompressedSetDuplicates(t *testing.T) {
176 sequence := Sequence{Seed: New()}

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…