MCPcopy Create free account
hub / github.com/aws/smithy-go / TestEncoder_Encode

Function TestEncoder_Encode

eventstream/encode_test.go:13–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestEncoder_Encode(t *testing.T) {
14 cases, err := readPositiveTests("testdata")
15 if err != nil {
16 t.Fatalf("failed to load positive tests, %v", err)
17 }
18
19 for _, c := range cases {
20 var w bytes.Buffer
21 encoder := NewEncoder()
22
23 err = encoder.Encode(&w, c.Decoded.Message())
24 if err != nil {
25 t.Fatalf("%s, failed to encode message, %v", c.Name, err)
26 }
27
28 if e, a := c.Encoded, w.Bytes(); !reflect.DeepEqual(e, a) {
29 t.Errorf("%s, expect:\n%v\nactual:\n%v\n", c.Name,
30 hex.Dump(e), hex.Dump(a))
31 }
32 }
33}
34
35func BenchmarkEncode(b *testing.B) {
36 var w bytes.Buffer

Callers

nothing calls this directly

Calls 6

EncodeMethod · 0.95
readPositiveTestsFunction · 0.85
MessageMethod · 0.80
ErrorfMethod · 0.80
NewEncoderFunction · 0.70
BytesMethod · 0.65

Tested by

no test coverage detected