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

Side by Side Diff: go/src/infra/gae/libs/wrapper/memory/binutils_test.go

Issue 1152383003: Simple memory testing for gae/wrapper (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@better_context_lite
Patch Set: fix capitalization Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(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 memory
6
7 import (
8 "bytes"
9 "testing"
10
11 . "github.com/smartystreets/goconvey/convey"
12 )
13
14 func TestBinutils(t *testing.T) {
15 Convey("Binary utilities", t, func() {
16 b := &bytes.Buffer{}
17
18 Convey("bytes", func() {
19 t := []byte("this is a test")
20 writeBytes(b, t)
21 Convey("good", func() {
22 r, err := readBytes(b)
23 So(err, ShouldBeNil)
24 So(r, ShouldResemble, t)
25 })
26 Convey("bad (truncated buffer)", func() {
27 bs := b.Bytes()
28 _, err := readBytes(bytes.NewBuffer(bs[:len(bs)- 4]))
29 So(err.Error(), ShouldContainSubstring, "readByt es: expected ")
30 })
31 Convey("bad (bad varint)", func() {
32 _, err := readBytes(bytes.NewBuffer([]byte{0x8f} ))
33 So(err.Error(), ShouldContainSubstring, "EOF")
34 })
35 })
36
37 Convey("strings", func() {
38 t := "this is a test"
39 writeString(b, t)
40 Convey("good", func() {
41 r, err := readString(b)
42 So(err, ShouldBeNil)
43 So(r, ShouldEqual, t)
44 })
45 Convey("bad (truncated buffer)", func() {
46 bs := b.Bytes()
47 _, err := readString(bytes.NewBuffer(bs[:len(bs) -4]))
48 So(err.Error(), ShouldContainSubstring, "readByt es: expected ")
49 })
50 })
51 })
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698