mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
28 lines
621 B
Go
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)
|
|
}
|