this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mst: add test FuzzKeyHasAllValidChars

authored by

Brad Fitzpatrick and committed by
bnewbold
5f7e4afd 0036e0e8

+18
+18
mst/mst_test.go
··· 7 7 "io" 8 8 "math/rand" 9 9 "os" 10 + "regexp" 10 11 "sort" 11 12 "testing" 12 13 ··· 527 528 t.Errorf("allocs (bytes) = %d; want 0", n) 528 529 } 529 530 _ = sink 531 + } 532 + 533 + // Verify that keyHasAllValidChars matches its documented regexp. 534 + func FuzzKeyHasAllValidChars(f *testing.F) { 535 + for _, seed := range [][]byte{{}} { 536 + f.Add(seed) 537 + } 538 + for i := 0; i < 256; i++ { 539 + f.Add([]byte{byte(i)}) 540 + } 541 + rx := regexp.MustCompile("^[a-zA-Z0-9_:.-]+$") 542 + f.Fuzz(func(t *testing.T, in []byte) { 543 + s := string(in) 544 + if a, b := rx.MatchString(s), keyHasAllValidChars(s); a != b { 545 + t.Fatalf("for %q, rx=%v, keyHasAllValidChars=%v", s, a, b) 546 + } 547 + }) 530 548 } 531 549 532 550 func BenchmarkLeadingZerosOnHash(b *testing.B) {