Skip to content

Commit 333dd95

Browse files
authored
trie: fix random test generator early terminate (#28590)
This change fixes a minor bug in the `randTest.Generate` function, which caused the `quick.Check` to be a no-op.
1 parent 2a20130 commit 333dd95

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

trie/trie_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ func TestRandomCases(t *testing.T) {
372372
// Instances of this test are created by Generate.
373373
type randTest []randTestStep
374374

375+
// compile-time interface check
376+
var _ quick.Generator = (randTest)(nil)
377+
375378
type randTestStep struct {
376379
op int
377380
key []byte // for opUpdate, opDelete, opGet
@@ -394,7 +397,7 @@ const (
394397
func (randTest) Generate(r *rand.Rand, size int) reflect.Value {
395398
var finishedFn = func() bool {
396399
size--
397-
return size > 0
400+
return size == 0
398401
}
399402
return reflect.ValueOf(generateSteps(finishedFn, r))
400403
}

0 commit comments

Comments
 (0)