mirror of
https://github.com/IBM/fp-go.git
synced 2025-08-10 22:31:32 +02:00
fix: implement foldMap for records
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2023 IBM Corp.
|
||||
// All rights reserved.
|
||||
// Copyright (c) 2023 IBM Corp.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,10 @@ import (
|
||||
|
||||
A "github.com/IBM/fp-go/array"
|
||||
"github.com/IBM/fp-go/internal/utils"
|
||||
Mg "github.com/IBM/fp-go/magma"
|
||||
O "github.com/IBM/fp-go/option"
|
||||
S "github.com/IBM/fp-go/string"
|
||||
T "github.com/IBM/fp-go/tuple"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -149,3 +151,28 @@ func TestCopyVsClone(t *testing.T) {
|
||||
assert.NotEqual(t, cpy, cln)
|
||||
assert.Equal(t, src, cpy)
|
||||
}
|
||||
|
||||
func TestFromArrayMap(t *testing.T) {
|
||||
src1 := A.From("a", "b", "c", "a")
|
||||
frm := FromArrayMap[string, string](Mg.Second[string]())
|
||||
|
||||
f := frm(T.Replicate2[string])
|
||||
|
||||
res1 := f(src1)
|
||||
|
||||
assert.Equal(t, map[string]string{
|
||||
"a": "a",
|
||||
"b": "b",
|
||||
"c": "c",
|
||||
}, res1)
|
||||
|
||||
src2 := A.From("A", "B", "C", "A")
|
||||
|
||||
res2 := f(src2)
|
||||
|
||||
assert.Equal(t, map[string]string{
|
||||
"A": "A",
|
||||
"B": "B",
|
||||
"C": "C",
|
||||
}, res2)
|
||||
}
|
||||
|
Reference in New Issue
Block a user