I have a table-driven test case like this one:
func CountWords(s string) map[string]int
func TestCountWords(t *testing.T) {
var tests = []struct {
input s
Simplest way:
assert.InDeltaMapValues(t, got, want, 0.0, "Word count wrong. Got %v, want %v", got, want)
Example:
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCountWords(t *testing.T) {
got := CountWords("hola hola que tal")
want := map[string]int{
"hola": 2,
"que": 1,
"tal": 1,
}
assert.InDeltaMapValues(t, got, want, 0.0, "Word count wrong. Got %v, want %v", got, want)
}