-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2022 Gregory Petrosyan <gregory.petrosyan@gmail.com> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
package rapid_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "pgregory.net/rapid" | ||
) | ||
|
||
func checkInt(t *T) { | ||
answer := Int().Draw(t, "answer") | ||
if answer == 42 { | ||
t.Fatalf("fuzzing works") | ||
} | ||
} | ||
|
||
func checkSlice(t *T) { | ||
slice := SliceOfN(Int(), 5, 5).Draw(t, "slice") | ||
if slice[0] < slice[1] && slice[1] < slice[2] && slice[2] < slice[3] && slice[3] < slice[4] { | ||
t.Fatalf("fuzzing works") | ||
} | ||
} | ||
|
||
func checkString(t *T) { | ||
hello := String().Draw(t, "hello") | ||
if hello == "world" { | ||
t.Fatalf("fuzzing works") | ||
} | ||
} | ||
|
||
func TestRapidInt(t *testing.T) { | ||
t.Skip() | ||
Check(t, checkInt) | ||
} | ||
func TestRapidSlice(t *testing.T) { | ||
t.Skip() | ||
Check(t, checkSlice) | ||
} | ||
func TestRapidString(t *testing.T) { | ||
t.Skip() | ||
Check(t, checkString) | ||
} | ||
|
||
func FuzzInt(f *testing.F) { f.Fuzz(MakeFuzz(checkInt)) } | ||
func FuzzSlice(f *testing.F) { f.Fuzz(MakeFuzz(checkSlice)) } | ||
func FuzzString(f *testing.F) { f.Fuzz(MakeFuzz(checkString)) } |