本文整理匯總了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")
}
}