Files
core/slices/diff_test.go
2023-07-06 10:27:56 +02:00

28 lines
621 B
Go

package slices
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestDiffComparable(t *testing.T) {
a := []string{"c", "d", "e", "f"}
b := []string{"a", "a", "b", "c", "d"}
added, removed := DiffComparable(a, b)
require.ElementsMatch(t, []string{"e", "f"}, added)
require.ElementsMatch(t, []string{"a", "a", "b"}, removed)
}
func TestDiffEqualer(t *testing.T) {
a := []String{"c", "d", "e", "f"}
b := []String{"a", "a", "b", "c", "d"}
added, removed := DiffComparable(a, b)
require.ElementsMatch(t, []String{"e", "f"}, added)
require.ElementsMatch(t, []String{"a", "a", "b"}, removed)
}