Skip to content

Commit 51307fd

Browse files
tklauserLukeShu
authored andcommitted
html: convert fuzz test to native Go fuzzing
Convert the existing gofuzz based fuzz test to a testing.F based fuzz test. Change-Id: Ieae69ba7fb17bd54d95c7bb2f4ed04c323c9f15f Reviewed-on: https://go-review.googlesource.com/c/go/+/494195 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> Cherry-picked-from: golang/go@200a01f
1 parent 6e12b94 commit 51307fd

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

html/fuzz.go

-31
This file was deleted.

html/fuzz_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package html
6+
7+
import "testing"
8+
9+
func FuzzEscapeUnescape(f *testing.F) {
10+
f.Fuzz(func(t *testing.T, v string) {
11+
e := EscapeString(v)
12+
u := UnescapeString(e)
13+
if u != v {
14+
t.Errorf("EscapeString(%q) = %q, UnescapeString(%q) = %q, want %q", v, e, e, u, v)
15+
}
16+
17+
// As per the documentation, this isn't always equal to v, so it makes
18+
// no sense to check for equality. It can still be interesting to find
19+
// panics in it though.
20+
EscapeString(UnescapeString(v))
21+
})
22+
}

0 commit comments

Comments
 (0)