github.com/batchcorp/thrift-iterator@v0.0.0-20220918180557-4c4a158fc6e9/test/level_1/pointer_test.go (about)

     1  package test
     2  
     3  import (
     4  	"testing"
     5  	"github.com/stretchr/testify/require"
     6  	"github.com/batchcorp/thrift-iterator/test"
     7  )
     8  
     9  func Test_unmarshal_ptr_int64(t *testing.T) {
    10  	should := require.New(t)
    11  	for _, c := range test.UnmarshalCombinations {
    12  		buf, proto := c.CreateProtocol()
    13  		proto.WriteI64(2)
    14  		proto.WriteListEnd()
    15  		var val *int64
    16  		should.NoError(c.Unmarshal(buf.Bytes(), &val))
    17  		should.Equal(int64(2), *val)
    18  	}
    19  }
    20  func Test_marshal_ptr_int64(t *testing.T) {
    21  	should := require.New(t)
    22  	for _, c := range test.MarshalCombinations {
    23  		val := int64(2)
    24  		output, err := c.Marshal(&val)
    25  		should.NoError(err)
    26  		iter := c.CreateIterator(output)
    27  		should.Equal(int64(2), iter.ReadInt64())
    28  	}
    29  }