1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-23 22:14:53 +02:00
Files
fp-go/record/monoid_test.go
Dr. Carsten Leue 48f38f2e43 fix: rework http support
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-16 22:46:18 +02:00

42 lines
646 B
Go

package record
import (
"testing"
S "github.com/ibm/fp-go/string"
"github.com/stretchr/testify/assert"
)
func TestUnionMonoid(t *testing.T) {
m := UnionMonoid[string](S.Semigroup())
e := Empty[string, string]()
x := map[string]string{
"a": "a1",
"b": "b1",
"c": "c1",
}
y := map[string]string{
"b": "b2",
"c": "c2",
"d": "d2",
}
res := map[string]string{
"a": "a1",
"b": "b1b2",
"c": "c1c2",
"d": "d2",
}
assert.Equal(t, x, m.Concat(x, m.Empty()))
assert.Equal(t, x, m.Concat(m.Empty(), x))
assert.Equal(t, x, m.Concat(x, e))
assert.Equal(t, x, m.Concat(e, x))
assert.Equal(t, res, m.Concat(x, y))
}