mirror of
https://github.com/IBM/fp-go.git
synced 2025-06-17 00:07:49 +02:00
28 lines
470 B
Go
28 lines
470 B
Go
package json
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
E "github.com/IBM/fp-go/either"
|
|
F "github.com/IBM/fp-go/function"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
type Json map[string]any
|
|
|
|
func TestJsonMarshal(t *testing.T) {
|
|
|
|
resRight := Unmarshal[Json]([]byte("{\"a\": \"b\"}"))
|
|
assert.True(t, E.IsRight(resRight))
|
|
|
|
resLeft := Unmarshal[Json]([]byte("{\"a\""))
|
|
assert.True(t, E.IsLeft(resLeft))
|
|
|
|
res1 := F.Pipe1(
|
|
resRight,
|
|
E.Chain(Marshal[Json]),
|
|
)
|
|
fmt.Println(res1)
|
|
}
|