Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package example
- import (
- "bytes"
- "math/rand"
- "reflect"
- "testing"
- "testing/quick"
- )
- type asciiString string
- func (asciiString) Generate(rand *rand.Rand, size int) reflect.Value {
- var buffer bytes.Buffer
- for i := 0; i < size; i++ {
- c := rand.Intn(127)
- buffer.WriteByte(byte(c))
- }
- s := asciiString(buffer.String())
- return reflect.ValueOf(s)
- }
- func TestRandomAscii(t *testing.T) {
- f := func(a asciiString) bool {
- s := string(a) /*s is a random string composed only of the first 128 ascii chars*/
- return do_something_with_random_input(s)
- }
- if err := quick.Check(f, nil); err != nil {
- t.Fatal(err)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement