(t *testing.T)
| 75 | } |
| 76 | |
| 77 | func TestEncBuiltinGobMarshalStruct(t *testing.T) { |
| 78 | s := RunServerOnPort(TEST_PORT) |
| 79 | defer s.Shutdown() |
| 80 | |
| 81 | ec := NewGobEncodedConn(t) |
| 82 | defer ec.Close() |
| 83 | ch := make(chan bool) |
| 84 | |
| 85 | me := &person{Name: "derek", Age: 22, Address: "140 New Montgomery St"} |
| 86 | me.Children = make(map[string]*person) |
| 87 | |
| 88 | me.Children["sam"] = &person{Name: "sam", Age: 19, Address: "140 New Montgomery St"} |
| 89 | me.Children["meg"] = &person{Name: "meg", Age: 17, Address: "140 New Montgomery St"} |
| 90 | |
| 91 | me.Assets = make(map[string]uint) |
| 92 | me.Assets["house"] = 1000 |
| 93 | me.Assets["car"] = 100 |
| 94 | |
| 95 | ec.Subscribe("gob_struct", func(p *person) { |
| 96 | if !reflect.DeepEqual(p, me) { |
| 97 | t.Fatalf("Did not receive the correct struct response") |
| 98 | } |
| 99 | ch <- true |
| 100 | }) |
| 101 | |
| 102 | ec.Publish("gob_struct", me) |
| 103 | if e := Wait(ch); e != nil { |
| 104 | t.Fatal("Did not receive the message") |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | func BenchmarkPublishGobStruct(b *testing.B) { |
| 109 | // stop benchmark for set-up |
nothing calls this directly
no test coverage detected