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

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: Delete "offset()" method. 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
« no previous file with comments | « common/recordio/size.go ('k') | server/logdog/storage/archive/storage.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..04f7e4441efe72aeb6378e58c4612eca3f307a7f
--- /dev/null
+++ b/common/recordio/size_test.go
@@ -0,0 +1,43 @@
+// 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"
+ "io/ioutil"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestFrameHeaderSize(t *testing.T) {
+ t.Parallel()
+
+ Convey(`Testing FrameHeaderSize`, t, func() {
+ 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(ioutil.Discard, data)
+ if err != nil {
+ panic(err)
+ }
+
+ So(amt-len(data), ShouldEqual, FrameHeaderSize(int64(len(data))))
+ })
+ }
+ }
+ })
+}
« no previous file with comments | « common/recordio/size.go ('k') | server/logdog/storage/archive/storage.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698