Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: common/recordio/size_test.go

Issue 1904503003: LogDog: Fix archived log stream read errors. (Closed) Base URL: https://github.com/luci/luci-go@hierarchy-check-first
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: common/recordio/size_test.go
diff --git a/common/recordio/size_test.go b/common/recordio/size_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..5376fb8217d112bd90ed2b96efdb59c26d570c40
--- /dev/null
+++ b/common/recordio/size_test.go
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package recordio
+
+import (
+ "bytes"
+ "fmt"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestFrameHeaderSize(t *testing.T) {
+ t.Parallel()
+
+ Convey(`Testing FrameHeaderSize`, t, func() {
nodir 2016/04/19 23:41:16 I believe this test must use binary.PutUvarint
dnj 2016/04/20 00:45:07 I'm not sure what you mean by "must use"? It indir
nodir 2016/04/20 16:42:57 yeah indeed
+ prev := -1
+ for i := 0; i < 5; i++ {
+ base := 1 << uint(7*i)
+ for delta := range []int{-1, 0, 1} {
+ base += delta
+ if base <= prev {
+ continue
+ }
+ prev = base
+
+ Convey(fmt.Sprintf(`Is accurate for buffer size %d.`, base), func() {
+ data := bytes.Repeat([]byte{0x55}, base)
+
+ amt, err := WriteFrame(devNull{}, data)
+ if err != nil {
+ panic(err)
+ }
+
+ So(amt-len(data), ShouldEqual, FrameHeaderSize(int64(len(data))))
+ })
+ }
+ }
+ })
+}
+
+type devNull struct{}
nodir 2016/04/19 23:41:17 Use ioutil.Discard
dnj 2016/04/20 00:45:07 Done.
+
+func (devNull) Write(d []byte) (int, error) {
+ return len(d), nil
+}

Powered by Google App Engine
This is Rietveld 408576698