From 970a78ace50a31a7142b5ea113f47874108cafa2 Mon Sep 17 00:00:00 2001 From: Andrey Burov Date: Thu, 25 Jan 2024 22:54:51 +0400 Subject: [PATCH] snippets: add fuzz function --- gosnippets/UltiSnips/go.snippets | 8 ++++++++ gosnippets/snippets/go.snip | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/gosnippets/UltiSnips/go.snippets b/gosnippets/UltiSnips/go.snippets index 7febcff0d0..c65d3e32f3 100644 --- a/gosnippets/UltiSnips/go.snippets +++ b/gosnippets/UltiSnips/go.snippets @@ -464,6 +464,14 @@ for _, tt := range tests { } endsnippet +# fuzz function +snippet fuzz "func FuzzXYZ(f *testing.F) { ... }" +func Fuzz${1:Function}(f *testing.F) { + f.Fuzz(func(t *testing.T, ${2}) { + ${0:${VISUAL}} + }) +} +endsnippet snippet hf "http.HandlerFunc" func ${1:handler}(w http.ResponseWriter, r *http.Request) { diff --git a/gosnippets/snippets/go.snip b/gosnippets/snippets/go.snip index 08b9e8b51d..17b78304ed 100644 --- a/gosnippets/snippets/go.snip +++ b/gosnippets/snippets/go.snip @@ -340,6 +340,14 @@ abbr var test = {...}{...} for {t.Run(){...}} } }) } +# fuzz function +snippet fuzz +abbr func FuzzXYZ(f *testing.F) { ... } + func Fuzz${1:Function}(f *testing.F) { + f.Fuzz(func(t *testing.T, ${2:ff}) { + ${0} + }) + } # test server snippet tsrv abbr ts := httptest.NewServer(...)