| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package recordio |
| 6 |
| 7 import ( |
| 8 "bytes" |
| 9 "fmt" |
| 10 "io/ioutil" |
| 11 "testing" |
| 12 |
| 13 . "github.com/smartystreets/goconvey/convey" |
| 14 ) |
| 15 |
| 16 func TestFrameHeaderSize(t *testing.T) { |
| 17 t.Parallel() |
| 18 |
| 19 Convey(`Testing FrameHeaderSize`, t, func() { |
| 20 prev := -1 |
| 21 for i := 0; i < 5; i++ { |
| 22 base := 1 << uint(7*i) |
| 23 for delta := range []int{-1, 0, 1} { |
| 24 base += delta |
| 25 if base <= prev { |
| 26 continue |
| 27 } |
| 28 prev = base |
| 29 |
| 30 Convey(fmt.Sprintf(`Is accurate for buffer size
%d.`, base), func() { |
| 31 data := bytes.Repeat([]byte{0x55}, base) |
| 32 |
| 33 amt, err := WriteFrame(ioutil.Discard, d
ata) |
| 34 if err != nil { |
| 35 panic(err) |
| 36 } |
| 37 |
| 38 So(amt-len(data), ShouldEqual, FrameHead
erSize(int64(len(data)))) |
| 39 }) |
| 40 } |
| 41 } |
| 42 }) |
| 43 } |
| OLD | NEW |