diff --git a/leaphash/fuzz_test.go b/leaphash/fuzz_test.go new file mode 100644 index 00000000..a84432b3 --- /dev/null +++ b/leaphash/fuzz_test.go @@ -0,0 +1,28 @@ +/* +Copyright (c) Facebook, Inc. and its affiliates. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package leaphash + +import "testing" + +// Keep this file to FuzzCompute alone. OSS-Fuzz compiles the file holding a fuzz +// target as a non-test file, so it cannot see anything declared in other +// _test.go files. +func FuzzCompute(f *testing.F) { + f.Fuzz(func(_ *testing.T, input string) { + _ = Compute(input) + }) +} diff --git a/leaphash/leaphash_test.go b/leaphash/leaphash_test.go index 1ea1af6d..c5034470 100644 --- a/leaphash/leaphash_test.go +++ b/leaphash/leaphash_test.go @@ -54,9 +54,3 @@ func TestHashIgnoresCarriageReturns(t *testing.T) { t.Fatalf("invalid hash value, got '%s', expected '%s'", hash, testDocHash) } } - -func FuzzCompute(f *testing.F) { - f.Fuzz(func(t *testing.T, input string) { - _ = Compute(input) - }) -}