1package storm 2 3import ( 4 "encoding/json" 5 "testing" 6) 7 8func TestServerZoneMarshal(t *testing.T) { 9 sz := ServerZone(123) 10 11 marshalled, err := json.Marshal(sz) 12 if err != nil { 13 t.Error(err) 14 } 15 if string(marshalled) != "123" { 16 t.Errorf("Marshal was incorrect, got %v", marshalled) 17 } 18} 19 20func TestServerZoneUnmarshal(t *testing.T) { 21 szJSON := []byte(`{ "id": 123 }`) 22 var sz ServerZone 23 24 err := json.Unmarshal(szJSON, &sz) 25 if err != nil { 26 t.Error(err) 27 } 28 t.Logf("%v", sz) 29 if sz != 123 { 30 t.Errorf("Unmarshal was incorrect, got %v", sz) 31 } 32} 33