github.com/chrislusf/greenpack@v3.7.1-0.20170911073826-ad5bd10b7c47+incompatible/_generated/mapsomething_test.go (about)

     1  package _generated
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  //go:generate greenpack
     8  
     9  type Row struct {
    10  	K []interface{} `msg:"K"`
    11  	V []interface{} `msg:"V"`
    12  	T int64         `msg:"T"`
    13  }
    14  
    15  // https://github.com/glycerine/greenpack/issues/1
    16  func TestMarshalMapOfConcreteType(t *testing.T) {
    17  
    18  	m := make(map[string][]float64)
    19  	m["def"] = []float64{1.2, 3.4}
    20  
    21  	row := Row{}
    22  	row.K = []interface{}{"abc"}
    23  	row.V = []interface{}{m}
    24  	_, err := row.MarshalMsg(nil)
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  }
    29  
    30  // this always worked fine
    31  func TestMarshalMapOfInterface(t *testing.T) {
    32  
    33  	m := make(map[string]interface{})
    34  	m["def"] = []float64{1.2, 3.4}
    35  
    36  	row := Row{}
    37  	row.K = []interface{}{"abc"}
    38  	row.V = []interface{}{m}
    39  	_, err := row.MarshalMsg(nil)
    40  	if err != nil {
    41  		panic(err)
    42  	}
    43  }