本文整理汇总了Golang中github.com/pquerna/ffjson/tests/types/ff.Everything.MySweetInterface方法的典型用法代码示例。如果您正苦于以下问题:Golang Everything.MySweetInterface方法的具体用法?Golang Everything.MySweetInterface怎么用?Golang Everything.MySweetInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pquerna/ffjson/tests/types/ff.Everything
的用法示例。
在下文中一共展示了Everything.MySweetInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestRoundTrip
func TestRoundTrip(t *testing.T) {
var record ff.Everything
var recordTripped ff.Everything
ff.NewEverything(&record)
buf1, err := json.Marshal(&record)
if err != nil {
t.Fatalf("Marshal: %v", err)
}
recordTripped.MySweetInterface = &ff.Cats{}
err = json.Unmarshal(buf1, &recordTripped)
if err != nil {
t.Fatalf("Unmarshal: %v", err)
}
good := reflect.DeepEqual(record.FooStruct, recordTripped.FooStruct)
if !good {
t.Fatalf("Expected: %v\n Got: %v", *record.FooStruct, *recordTripped.FooStruct)
}
record.FooStruct = nil
recordTripped.FooStruct = nil
good = reflect.DeepEqual(record, recordTripped)
if !good {
t.Fatalf("Expected: %v\n Got: %v", record, recordTripped)
}
if recordTripped.SuperBool != true {
t.Fatal("Embeded struct didn't Unmarshal")
}
if recordTripped.Something != 99 {
t.Fatal("Embeded nonexported-struct didn't Unmarshal")
}
}