aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Dietz <noahdietz@users.noreply.github.com>2023-08-22 08:58:23 -0700
committerGitHub <noreply@github.com>2023-08-22 08:58:23 -0700
commit542ddabd47d7bfa79359b7b4e2af7f975354e35f (patch)
treec50f6cc705e30ce0caf5150903a5fa3662b70204
parent06716f6a60da5ba158f1d53a8236a534968ff76e (diff)
downloadgoogle-uuid-542ddabd47d7bfa79359b7b4e2af7f975354e35f.tar.gz
chore(tests): add Fuzz tests (#128)
-rw-r--r--uuid_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/uuid_test.go b/uuid_test.go
index e98d0fe..429ac7a 100644
--- a/uuid_test.go
+++ b/uuid_test.go
@@ -569,6 +569,39 @@ func TestIsWrongLength(t *testing.T) {
}
}
+func FuzzParse(f *testing.F) {
+ for _, tt := range tests {
+ f.Add(tt.in)
+ f.Add(strings.ToUpper(tt.in))
+ }
+ f.Fuzz(func(t *testing.T, in string) {
+ Parse(in)
+ })
+}
+
+func FuzzParseBytes(f *testing.F) {
+ for _, tt := range tests {
+ f.Add([]byte(tt.in))
+ }
+ f.Fuzz(func(t *testing.T, in []byte) {
+ ParseBytes(in)
+ })
+}
+
+func FuzzFromBytes(f *testing.F) {
+ // Copied from TestFromBytes.
+ f.Add([]byte{
+ 0x7d, 0x44, 0x48, 0x40,
+ 0x9d, 0xc0,
+ 0x11, 0xd1,
+ 0xb2, 0x45,
+ 0x5f, 0xfd, 0xce, 0x74, 0xfa, 0xd2,
+ })
+ f.Fuzz(func(t *testing.T, in []byte) {
+ FromBytes(in)
+ })
+}
+
var asString = "f47ac10b-58cc-0372-8567-0e02b2c3d479"
var asBytes = []byte(asString)