(t *testing.T)
| 43 | } |
| 44 | |
| 45 | func TestSkipPrimitiveConsumesExactEncoding(t *testing.T) { |
| 46 | tests := []struct { |
| 47 | name string |
| 48 | typeID TypeId |
| 49 | write func(*ByteBuffer) |
| 50 | }{ |
| 51 | { |
| 52 | name: "int32", |
| 53 | typeID: INT32, |
| 54 | write: func(buf *ByteBuffer) { buf.WriteInt32(0x01020304) }, |
| 55 | }, |
| 56 | { |
| 57 | name: "varint32", |
| 58 | typeID: VARINT32, |
| 59 | write: func(buf *ByteBuffer) { buf.WriteVarint32(300) }, |
| 60 | }, |
| 61 | { |
| 62 | name: "int64", |
| 63 | typeID: INT64, |
| 64 | write: func(buf *ByteBuffer) { buf.WriteInt64(0x0102030405060708) }, |
| 65 | }, |
| 66 | { |
| 67 | name: "varint64", |
| 68 | typeID: VARINT64, |
| 69 | write: func(buf *ByteBuffer) { buf.WriteVarint64(1 << 35) }, |
| 70 | }, |
| 71 | { |
| 72 | name: "tagged_int64_small", |
| 73 | typeID: TAGGED_INT64, |
| 74 | write: func(buf *ByteBuffer) { buf.WriteTaggedInt64(1073741823) }, |
| 75 | }, |
| 76 | { |
| 77 | name: "tagged_int64_large", |
| 78 | typeID: TAGGED_INT64, |
| 79 | write: func(buf *ByteBuffer) { buf.WriteTaggedInt64(1 << 40) }, |
| 80 | }, |
| 81 | { |
| 82 | name: "tagged_uint64_small", |
| 83 | typeID: TAGGED_UINT64, |
| 84 | write: func(buf *ByteBuffer) { buf.WriteTaggedUint64(0x7fffffff) }, |
| 85 | }, |
| 86 | { |
| 87 | name: "tagged_uint64_large", |
| 88 | typeID: TAGGED_UINT64, |
| 89 | write: func(buf *ByteBuffer) { buf.WriteTaggedUint64(1 << 40) }, |
| 90 | }, |
| 91 | } |
| 92 | |
| 93 | for _, tc := range tests { |
| 94 | t.Run(tc.name, func(t *testing.T) { |
| 95 | f := New(WithXlang(true), WithCompatible(false)) |
| 96 | buf := NewByteBuffer(nil) |
| 97 | tc.write(buf) |
| 98 | wantIndex := buf.WriterIndex() |
| 99 | buf.WriteByte(0x7f) |
| 100 | |
| 101 | f.readCtx.SetData(buf.Bytes()) |
| 102 | skipValue( |
nothing calls this directly
no test coverage detected