1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00

fix: more testing

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2024-05-25 15:41:32 +02:00
parent 598a7b261b
commit 391754e5a6
11 changed files with 367 additions and 1 deletions

View File

@@ -17,11 +17,13 @@ package readerioeither
import (
"context"
"fmt"
"testing"
A "github.com/IBM/fp-go/array"
ET "github.com/IBM/fp-go/either"
F "github.com/IBM/fp-go/function"
TST "github.com/IBM/fp-go/internal/testing"
"github.com/stretchr/testify/assert"
)
@@ -37,3 +39,33 @@ func TestTraverseArray(t *testing.T) {
assert.Equal(t, ET.Right[string]([]string{"aa", "bb"}), F.Pipe1([]string{"a", "b"}, f)(ctx)())
assert.Equal(t, ET.Left[[]string]("e"), F.Pipe1([]string{"a", ""}, f)(ctx)())
}
func TestSequenceArray(t *testing.T) {
s := TST.SequenceArrayTest(
FromStrictEquals[context.Context, error, bool]()(context.Background()),
Pointed[context.Context, error, string](),
Pointed[context.Context, error, bool](),
Functor[context.Context, error, []string, bool](),
SequenceArray[context.Context, error, string],
)
for i := 0; i < 10; i++ {
t.Run(fmt.Sprintf("TestSequenceArray %d", i), s(i))
}
}
func TestSequenceArrayError(t *testing.T) {
s := TST.SequenceArrayErrorTest(
FromStrictEquals[context.Context, error, bool]()(context.Background()),
Left[context.Context, string, error],
Left[context.Context, bool, error],
Pointed[context.Context, error, string](),
Pointed[context.Context, error, bool](),
Functor[context.Context, error, []string, bool](),
SequenceArray[context.Context, error, string],
)
// run across four bits
s(4)(t)
}