diff --git a/unstable/difft/difft.go b/unstable/difft/difft.go index ba018e26c..28a6a29a4 100644 --- a/unstable/difft/difft.go +++ b/unstable/difft/difft.go @@ -79,14 +79,13 @@ func (edits Edits[T]) apply(xs []T, equals func(T, T) bool) ([]T, error) { return output, nil } -type DiffTOptions[T any] struct { +type DiffOptions[T any] struct { Equals func(T, T) bool } -func DiffT[T any](xs, ys []T, opts DiffTOptions[T]) Edits[T] { - eq := opts.Equals - if eq == nil { - eq = func(x T, y T) bool { +func DiffT[T any](xs, ys []T, opts DiffOptions[T]) Edits[T] { + if opts.Equals == nil { + opts.Equals = func(x T, y T) bool { return any(x) == any(y) } } diff --git a/unstable/difft/difft_test.go b/unstable/difft/difft_test.go index c7d38d085..80aef22c6 100644 --- a/unstable/difft/difft_test.go +++ b/unstable/difft/difft_test.go @@ -22,6 +22,7 @@ import ( ) func TestDiffAppliesCorrectly(t *testing.T) { + t.Parallel() rapid.Check(t, func(t *rapid.T) { s1 := rapid.StringMatching(`^[abc]{0,5}`).Draw(t, "s1") s2 := rapid.StringMatching(`^[abc]{0,5}`).Draw(t, "s2") @@ -29,7 +30,7 @@ func TestDiffAppliesCorrectly(t *testing.T) { eq := func(b1, b2 byte) bool { return b1 == b2 } - edits := DiffT([]byte(s1), []byte(s2), DiffTOptions[byte]{ + edits := DiffT([]byte(s1), []byte(s2), DiffOptions[byte]{ Equals: eq, }) @@ -50,11 +51,12 @@ func TestDiffAppliesCorrectly(t *testing.T) { } func TestDiff(t *testing.T) { + t.Parallel() eq := func(a, b byte) bool { return a == b } input := []byte(`mario`) - dd := DiffT(input, []byte(`darius`), DiffTOptions[byte]{Equals: eq}) + dd := DiffT(input, []byte(`darius`), DiffOptions[byte]{Equals: eq}) assert.Equal(t, Remove, dd[0].Change) assert.Equal(t, Insert, dd[1].Change) assert.Equal(t, Keep, dd[2].Change) diff --git a/unstable/difft/matrix_test.go b/unstable/difft/matrix_test.go index a0a681a3b..138050266 100644 --- a/unstable/difft/matrix_test.go +++ b/unstable/difft/matrix_test.go @@ -21,6 +21,7 @@ import ( ) func TestMatrix(t *testing.T) { + t.Parallel() m := newMatrix(3, 3) m.set(1, 1, 42) assert.Equal(t, 42, m.get(1, 1))