github.com/Odesyuk/pop@v4.13.1+incompatible/slices/map_test.go (about)

     1  package slices
     2  
     3  import (
     4  	"encoding/json"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func Test_Map_UnmarshalText(t *testing.T) {
    11  	r := require.New(t)
    12  
    13  	m := Map{}
    14  	err := m.UnmarshalText([]byte(`{"a":"b"}`))
    15  	r.NoError(err)
    16  	r.Equal("b", m["a"])
    17  }
    18  
    19  func Test_Map_MarshalJSON(t *testing.T) {
    20  	r := require.New(t)
    21  
    22  	m := Map{"a": "b"}
    23  	b, err := json.Marshal(m)
    24  	r.NoError(err)
    25  	r.Equal([]byte(`{"a":"b"}`), b)
    26  }