(t *testing.T)
| 195 | } |
| 196 | |
| 197 | func TestEncBuiltinJsonMarshalStruct(t *testing.T) { |
| 198 | s := RunServerOnPort(TEST_PORT) |
| 199 | defer s.Shutdown() |
| 200 | |
| 201 | ec := NewJsonEncodedConn(t) |
| 202 | defer ec.Close() |
| 203 | ch := make(chan bool) |
| 204 | |
| 205 | me := &person{Name: "derek", Age: 22, Address: "140 New Montgomery St"} |
| 206 | me.Children = make(map[string]*person) |
| 207 | |
| 208 | me.Children["sam"] = &person{Name: "sam", Age: 19, Address: "140 New Montgomery St"} |
| 209 | me.Children["meg"] = &person{Name: "meg", Age: 17, Address: "140 New Montgomery St"} |
| 210 | |
| 211 | me.Assets = make(map[string]uint) |
| 212 | me.Assets["house"] = 1000 |
| 213 | me.Assets["car"] = 100 |
| 214 | |
| 215 | ec.Subscribe("json_struct", func(p *person) { |
| 216 | if !reflect.DeepEqual(p, me) { |
| 217 | t.Fatal("Did not receive the correct struct response") |
| 218 | } |
| 219 | ch <- true |
| 220 | }) |
| 221 | |
| 222 | ec.Publish("json_struct", me) |
| 223 | if e := Wait(ch); e != nil { |
| 224 | t.Fatal("Did not receive the message") |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | func BenchmarkJsonMarshalStruct(b *testing.B) { |
| 229 | me := &person{Name: "derek", Age: 22, Address: "140 New Montgomery St"} |
nothing calls this directly
no test coverage detected