MCPcopy
hub / github.com/nats-io/nats.go / TestEncBuiltinMarshalFloat32

Function TestEncBuiltinMarshalFloat32

test/enc_test.go:186–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestEncBuiltinMarshalFloat32(t *testing.T) {
187 s := RunServerOnPort(TEST_PORT)
188 defer s.Shutdown()
189
190 ec := NewDefaultEConn(t)
191 defer ec.Close()
192 ch := make(chan bool)
193
194 testN := float32(22)
195
196 ec.Subscribe("enc_float", func(n float32) {
197 if n != testN {
198 t.Fatalf("Received test number of %f, wanted %f\n", n, testN)
199 }
200 ch <- true
201 })
202 ec.Publish("enc_float", testN)
203 if e := Wait(ch); e != nil {
204 if ec.LastError() != nil {
205 e = ec.LastError()
206 }
207 t.Fatalf("Did not receive the message: %s", e)
208 }
209}
210
211func TestEncBuiltinMarshalFloat64(t *testing.T) {
212 s := RunServerOnPort(TEST_PORT)

Callers

nothing calls this directly

Calls 8

NewDefaultEConnFunction · 0.85
FatalfMethod · 0.80
RunServerOnPortFunction · 0.70
WaitFunction · 0.70
SubscribeMethod · 0.65
PublishMethod · 0.65
CloseMethod · 0.45
LastErrorMethod · 0.45

Tested by

no test coverage detected