dict: refact test
This commit is contained in:
parent
73ab7dc92d
commit
dd61fb557b
@ -2,13 +2,19 @@ package dictionary
|
|||||||
|
|
||||||
import "testing"
|
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) {
|
func TestSearch(t *testing.T) {
|
||||||
dictionary := map[string]string{"test": "this is just a test"}
|
dictionary := map[string]string{"test": "this is just a test"}
|
||||||
|
|
||||||
got := Search(dictionary, "test")
|
got := Search(dictionary, "test")
|
||||||
want := "this is just a test"
|
want := "this is just a test"
|
||||||
|
|
||||||
if got != want {
|
assertStrings(t, got, want)
|
||||||
t.Errorf("got %q want %q given %q", got, want, "test")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user