TestDecodeMsgPack verifies msgpack decoding functionality
(t *testing.T)
| 57 | |
| 58 | // TestDecodeMsgPack verifies msgpack decoding functionality |
| 59 | func TestDecodeMsgPack(t *testing.T) { |
| 60 | type testStruct struct { |
| 61 | Name string `json:"name"` |
| 62 | Value int `json:"value"` |
| 63 | } |
| 64 | |
| 65 | original := testStruct{ |
| 66 | Name: "test", |
| 67 | Value: 42, |
| 68 | } |
| 69 | |
| 70 | // Encode |
| 71 | encoded, err := EncodeMsgPack(original) |
| 72 | if err != nil { |
| 73 | t.Fatalf("EncodeMsgPack() failed: %v", err) |
| 74 | } |
| 75 | |
| 76 | // Decode |
| 77 | var decoded testStruct |
| 78 | err = DecodeMsgPack(encoded, &decoded) |
| 79 | if err != nil { |
| 80 | t.Fatalf("DecodeMsgPack() failed: %v", err) |
| 81 | } |
| 82 | |
| 83 | // Verify |
| 84 | if decoded.Name != original.Name || decoded.Value != original.Value { |
| 85 | t.Errorf("Decoded struct doesn't match original. Got %+v, want %+v", decoded, original) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // TestBufferPooling verifies that buffer pooling works correctly |
| 90 | func TestBufferPooling(t *testing.T) { |
nothing calls this directly
no test coverage detected