github.com/smugmug/godynamo@v0.0.0-20151122084750-7913028f6623/types/itemcollectionmetrics/itemcollectionmetrics_test.go (about) 1 package itemcollectionmetrics 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "testing" 7 ) 8 9 func TestExpectedMarshal(t *testing.T) { 10 s := []string{ 11 `{"ItemCollectionKey":{"AttributeValue":{"S":"a string"}},"SizeEstimateRangeGB":[0,10]}`, 12 } 13 for i, v := range s { 14 var a ItemCollectionMetrics 15 um_err := json.Unmarshal([]byte(v), &a) 16 if um_err != nil { 17 t.Errorf("cannot unmarshal\n") 18 } 19 20 json, jerr := json.Marshal(a) 21 if jerr != nil { 22 t.Errorf("cannot marshal\n") 23 } 24 if len(s[i]) != len(string(json)) { 25 e := fmt.Sprintf("\n%s\n%s\nshould be same",s[i],string(json)) 26 t.Errorf(e) 27 } 28 } 29 }