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

Side by Side Diff: service/datastore/serialize/invertible_test.go

Issue 1302813003: impl/memory: Implement Queries (Closed) Base URL: https://github.com/luci/gae.git@add_multi_iterator
Patch Set: stringSet everywhere Created 5 years, 3 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
« no previous file with comments | « service/datastore/serialize/invertible.go ('k') | service/datastore/serialize/serialize.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package serialize 5 package serialize
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "testing" 9 "testing"
10 10
(...skipping 29 matching lines...) Expand all
40 Convey("ReadByte", func() { 40 Convey("ReadByte", func() {
41 for i := 0; i < 5; i++ { 41 for i := 0; i < 5; i++ {
42 b, err := inv.ReadByte() 42 b, err := inv.ReadByte()
43 So(err, ShouldBeNil) 43 So(err, ShouldBeNil)
44 So(b, ShouldEqual, byte('a')+byt e(i)) 44 So(b, ShouldEqual, byte('a')+byt e(i))
45 } 45 }
46 }) 46 })
47 }) 47 })
48 }) 48 })
49 Convey("inverted writing", func() { 49 Convey("inverted writing", func() {
50 » » » inv.Invert() 50 » » » inv.SetInvert(true)
51 Convey("Write", func() { 51 Convey("Write", func() {
52 n, err := inv.Write([]byte("hello")) 52 n, err := inv.Write([]byte("hello"))
53 So(err, ShouldBeNil) 53 So(err, ShouldBeNil)
54 So(n, ShouldEqual, 5) 54 So(n, ShouldEqual, 5)
55 So(inv.String(), ShouldEqual, "\x97\x9a\x93\x93\ x90") 55 So(inv.String(), ShouldEqual, "\x97\x9a\x93\x93\ x90")
56 }) 56 })
57 Convey("WriteString", func() { 57 Convey("WriteString", func() {
58 n, err := inv.WriteString("hello") 58 n, err := inv.WriteString("hello")
59 So(err, ShouldBeNil) 59 So(err, ShouldBeNil)
60 So(n, ShouldEqual, 5) 60 So(n, ShouldEqual, 5)
61 So(inv.String(), ShouldEqual, "\x97\x9a\x93\x93\ x90") 61 So(inv.String(), ShouldEqual, "\x97\x9a\x93\x93\ x90")
62 }) 62 })
63 Convey("WriteByte", func() { 63 Convey("WriteByte", func() {
64 for i := byte('a'); i < 'f'; i++ { 64 for i := byte('a'); i < 'f'; i++ {
65 err := inv.WriteByte(i) 65 err := inv.WriteByte(i)
66 So(err, ShouldBeNil) 66 So(err, ShouldBeNil)
67 } 67 }
68 So(inv.String(), ShouldEqual, "\x9e\x9d\x9c\x9b\ x9a") 68 So(inv.String(), ShouldEqual, "\x9e\x9d\x9c\x9b\ x9a")
69 69
70 Convey("ReadByte", func() { 70 Convey("ReadByte", func() {
71 for i := 0; i < 5; i++ { 71 for i := 0; i < 5; i++ {
72 b, err := inv.ReadByte() 72 b, err := inv.ReadByte()
73 So(err, ShouldBeNil) 73 So(err, ShouldBeNil)
74 So(b, ShouldEqual, byte('a')+byt e(i)) // inverted back to normal 74 So(b, ShouldEqual, byte('a')+byt e(i)) // inverted back to normal
75 } 75 }
76 }) 76 })
77 }) 77 })
78 }) 78 })
79 Convey("Toggleable", func() { 79 Convey("Toggleable", func() {
80 » » » inv.Invert() 80 » » » inv.SetInvert(true)
81 n, err := inv.Write([]byte("hello")) 81 n, err := inv.Write([]byte("hello"))
82 So(err, ShouldBeNil) 82 So(err, ShouldBeNil)
83 » » » inv.Invert() 83 » » » inv.SetInvert(false)
84 n, err = inv.Write([]byte("hello")) 84 n, err = inv.Write([]byte("hello"))
85 So(n, ShouldEqual, 5) 85 So(n, ShouldEqual, 5)
86 So(inv.String(), ShouldEqual, "\x97\x9a\x93\x93\x90hello ") 86 So(inv.String(), ShouldEqual, "\x97\x9a\x93\x93\x90hello ")
87 }) 87 })
88 }) 88 })
89 } 89 }
OLDNEW
« no previous file with comments | « service/datastore/serialize/invertible.go ('k') | service/datastore/serialize/serialize.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698