Skip to content

Generated strings are too short #81

@dt-eric-lefevreardant

Description

@dt-eric-lefevreardant

When calling rapid.String(), I expected the generated strings to vary in length from 0 to a large number, possibly math.MaxInt, if I interpret this line correctly:

maxLen = math.MaxInt

However, in my experience, the length is very limited, apparently rarely more than 100 characters. Take this test:

func Test_RapidGeneratesOnlySmallStrings(t *testing.T) {
	maxLength := 0

	rapid.Check(t, func(t *rapid.T) {
		str := rapid.String().Draw(t, "str")
		maxLength = max(len(str), maxLength)
	})

	fmt.Println("maxLength:", maxLength)
}

I could never get more than "maxLength:102". Here is how I ran the test:

% go test . -run Test_RapidGeneratesOnlySmallStrings -v -rapid.checks=10_000 -rapid.seed=1

For good measure, I tried changing the seed, but it didn't make much difference.

Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions