Skip to content

Commit 542ddab

Browse files
authored
chore(tests): add Fuzz tests (#128)
1 parent 06716f6 commit 542ddab

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

uuid_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,39 @@ func TestIsWrongLength(t *testing.T) {
569569
}
570570
}
571571

572+
func FuzzParse(f *testing.F) {
573+
for _, tt := range tests {
574+
f.Add(tt.in)
575+
f.Add(strings.ToUpper(tt.in))
576+
}
577+
f.Fuzz(func(t *testing.T, in string) {
578+
Parse(in)
579+
})
580+
}
581+
582+
func FuzzParseBytes(f *testing.F) {
583+
for _, tt := range tests {
584+
f.Add([]byte(tt.in))
585+
}
586+
f.Fuzz(func(t *testing.T, in []byte) {
587+
ParseBytes(in)
588+
})
589+
}
590+
591+
func FuzzFromBytes(f *testing.F) {
592+
// Copied from TestFromBytes.
593+
f.Add([]byte{
594+
0x7d, 0x44, 0x48, 0x40,
595+
0x9d, 0xc0,
596+
0x11, 0xd1,
597+
0xb2, 0x45,
598+
0x5f, 0xfd, 0xce, 0x74, 0xfa, 0xd2,
599+
})
600+
f.Fuzz(func(t *testing.T, in []byte) {
601+
FromBytes(in)
602+
})
603+
}
604+
572605
var asString = "f47ac10b-58cc-0372-8567-0e02b2c3d479"
573606
var asBytes = []byte(asString)
574607

0 commit comments

Comments
 (0)