本文整理汇总了Golang中github.com/andres-erbsen/protobuf/jsonpb.UnmarshalString函数的典型用法代码示例。如果您正苦于以下问题:Golang UnmarshalString函数的具体用法?Golang UnmarshalString怎么用?Golang UnmarshalString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UnmarshalString函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestFooJSON
func TestFooJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedFoo(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Foo{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
}
开发者ID:andres-erbsen,项目名称:protobuf,代码行数:18,代码来源:protopb_test.go
示例2: TestEncodedAuthorizationPolicyJSON
func TestEncodedAuthorizationPolicyJSON(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedEncodedAuthorizationPolicy(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatal(err)
}
msg := &EncodedAuthorizationPolicy{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatal(err)
}
if err := p.VerboseEqual(msg); err != nil {
t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
}
if !p.Equal(msg) {
t.Fatalf("%#v !Json Equal %#v", msg, p)
}
}
开发者ID:Liamsi,项目名称:coname,代码行数:20,代码来源:AuthorizationPolicypr_test.go
示例3: TestVerifierStateJSON
func TestVerifierStateJSON(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedVerifierState(popr, true)
marshaler := github_com_andres_erbsen_protobuf_jsonpb.Marshaller{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatal(err)
}
msg := &VerifierState{}
err = github_com_andres_erbsen_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatal(err)
}
if err := p.VerboseEqual(msg); err != nil {
t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
}
if !p.Equal(msg) {
t.Fatalf("%#v !Json Equal %#v", msg, p)
}
}
开发者ID:postfix,项目名称:coname,代码行数:20,代码来源:verifierlocalpb_test.go
示例4: TestMessageWithMapJSON
func TestMessageWithMapJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedMessageWithMap(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &MessageWithMap{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if err := p.VerboseEqual(msg); err != nil {
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
}
开发者ID:andres-erbsen,项目名称:protobuf,代码行数:21,代码来源:theproto3pb_test.go
示例5: TestEmailProofByClientCertJSON
func TestEmailProofByClientCertJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedEmailProofByClientCert(popr, true)
marshaler := github_com_andres_erbsen_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &EmailProofByClientCert{}
err = github_com_andres_erbsen_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if err := p.VerboseEqual(msg); err != nil {
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
}
开发者ID:andres-erbsen,项目名称:coname-mit,代码行数:21,代码来源:keyserverconfigpb_test.go
注:本文中的github.com/andres-erbsen/protobuf/jsonpb.UnmarshalString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论