TestSkipStruct2 tests skip struct.
(t *testing.T)
| 231 | |
| 232 | // TestSkipStruct2 tests skip struct. |
| 233 | func TestSkipStruct2(t *testing.T) { |
| 234 | b := NewBuffer() |
| 235 | |
| 236 | err := b.WriteHead(StructBegin, 1) |
| 237 | if err != nil { |
| 238 | t.Error(err) |
| 239 | } |
| 240 | err = b.WriteHead(StructBegin, 1) |
| 241 | if err != nil { |
| 242 | t.Error(err) |
| 243 | } |
| 244 | |
| 245 | err = b.WriteHead(StructEnd, 0) |
| 246 | if err != nil { |
| 247 | t.Error(err) |
| 248 | } |
| 249 | err = b.WriteHead(StructEnd, 0) |
| 250 | if err != nil { |
| 251 | t.Error(err) |
| 252 | } |
| 253 | err = b.WriteInt64(math.MinInt64, byte(10)) |
| 254 | if err != nil { |
| 255 | t.Error(err) |
| 256 | } |
| 257 | |
| 258 | rb := r(b) |
| 259 | |
| 260 | have, err := rb.SkipTo(StructBegin, 1, true) |
| 261 | if err != nil || !have { |
| 262 | t.Error(err) |
| 263 | } |
| 264 | err = rb.SkipToStructEnd() |
| 265 | if err != nil { |
| 266 | t.Error(err) |
| 267 | } |
| 268 | var data int64 |
| 269 | err = rb.ReadInt64(&data, byte(10), true) |
| 270 | if err != nil { |
| 271 | t.Error(err) |
| 272 | } |
| 273 | if data != math.MinInt64 { |
| 274 | t.Error("no eq.") |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // BenchmarkUint32 benchmarks the write and read the uint32 type. |
| 279 | func BenchmarkUint32(t *testing.B) { |
nothing calls this directly
no test coverage detected