From dd61fb557bc84a2e431d72848770ba002cf66652 Mon Sep 17 00:00:00 2001 From: vinchent Date: Wed, 11 Sep 2024 14:07:00 +0200 Subject: [PATCH] dict: refact test --- dictionary/dictionary_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dictionary/dictionary_test.go b/dictionary/dictionary_test.go index 737bbd9..bf7b5db 100644 --- a/dictionary/dictionary_test.go +++ b/dictionary/dictionary_test.go @@ -2,13 +2,19 @@ package dictionary import "testing" +func assertStrings(t testing.TB, got, want string) { + t.Helper() + + if got != want { + t.Errorf("got %q want %q given %q", got, want, "test") + } +} + func TestSearch(t *testing.T) { dictionary := map[string]string{"test": "this is just a test"} got := Search(dictionary, "test") want := "this is just a test" - if got != want { - t.Errorf("got %q want %q given %q", got, want, "test") - } + assertStrings(t, got, want) }