Skip to content

Commit

Permalink
feat: Fuzzing test on Base64 encoding and decoding (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-leydier authored Mar 29, 2022
1 parent 5e4bc7e commit f15028b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions conversion/base64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ func TestBase64EncodeDecodeInverse(t *testing.T) {
}
}
}

func FuzzBase64Encode(f *testing.F) {
f.Add([]byte("hello"))
f.Fuzz(func(t *testing.T, input []byte) {
result := Base64Decode(Base64Encode(input))
for i := 0; i < len(input); i++ {
if result[i] != input[i] {
t.Fatalf("with input '%s' - expected '%s', got '%s' (mismatch at position %d)", input, input, result, i)
}
}
})
}

0 comments on commit f15028b

Please sign in to comment.