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

Side by Side Diff: impl/memory/gkvlite_iter_test.go

Issue 1365743002: Refactor serialization helpers from impl/memory -> service/datastore/serialize (Closed) Base URL: https://github.com/luci/gae.git@estimate_size
Patch Set: fix comments 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 | « impl/memory/gkvlite_iter.go ('k') | service/datastore/serialize/binary_tools.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 memory 5 package memory
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "testing" 9 "testing"
10 10
11 "github.com/luci/gae/service/datastore/serialize"
11 "github.com/luci/gkvlite" 12 "github.com/luci/gkvlite"
12 "github.com/luci/luci-go/common/cmpbin" 13 "github.com/luci/luci-go/common/cmpbin"
13 . "github.com/smartystreets/goconvey/convey" 14 . "github.com/smartystreets/goconvey/convey"
14 ) 15 )
15 16
16 func mkNum(n int64) []byte { 17 func mkNum(n int64) []byte {
17 buf := &bytes.Buffer{} 18 buf := &bytes.Buffer{}
18 _, err := cmpbin.WriteInt(buf, n) 19 _, err := cmpbin.WriteInt(buf, n)
19 memoryCorruption(err) 20 memoryCorruption(err)
20 21
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 {3, 10}, 158 {3, 10},
158 {3, 11}, 159 {3, 11},
159 } 160 }
160 161
161 valBytes := make([][]byte, len(vals)) 162 valBytes := make([][]byte, len(vals))
162 for i, nms := range vals { 163 for i, nms := range vals {
163 numbs := make([][]byte, len(nms)) 164 numbs := make([][]byte, len(nms))
164 for j, n := range nms { 165 for j, n := range nms {
165 numbs[j] = mkNum(n) 166 numbs[j] = mkNum(n)
166 } 167 }
167 » » valBytes[i] = bjoin(numbs...) 168 » » valBytes[i] = serialize.Join(numbs...)
168 } 169 }
169 170
170 otherVals := [][]int64{ 171 otherVals := [][]int64{
171 {3, 0}, 172 {3, 0},
172 {4, 10}, 173 {4, 10},
173 {19, 7}, 174 {19, 7},
174 {20, 2}, 175 {20, 2},
175 {20, 3}, 176 {20, 3},
176 {20, 4}, 177 {20, 4},
177 {20, 8}, 178 {20, 8},
178 {20, 11}, 179 {20, 11},
179 } 180 }
180 181
181 otherValBytes := make([][]byte, len(otherVals)) 182 otherValBytes := make([][]byte, len(otherVals))
182 for i, nms := range otherVals { 183 for i, nms := range otherVals {
183 numbs := make([][]byte, len(nms)) 184 numbs := make([][]byte, len(nms))
184 for i, n := range nms { 185 for i, n := range nms {
185 numbs[i] = mkNum(n) 186 numbs[i] = mkNum(n)
186 } 187 }
187 » » otherValBytes[i] = bjoin(numbs...) 188 » » otherValBytes[i] = serialize.Join(numbs...)
188 } 189 }
189 190
190 Convey("Test MultiIterator", t, func() { 191 Convey("Test MultiIterator", t, func() {
191 s := newMemStore() 192 s := newMemStore()
192 c := s.SetCollection("zup1", nil) 193 c := s.SetCollection("zup1", nil)
193 for _, row := range valBytes { 194 for _, row := range valBytes {
194 c.Set(row, []byte{}) 195 c.Set(row, []byte{})
195 } 196 }
196 c2 := s.SetCollection("zup2", nil) 197 c2 := s.SetCollection("zup2", nil)
197 for _, row := range otherValBytes { 198 for _, row := range otherValBytes {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 So(readNum(suffix), ShouldEqual, vals[i][1]) 270 So(readNum(suffix), ShouldEqual, vals[i][1])
270 i++ 271 i++
271 return false 272 return false
272 }) 273 })
273 So(i, ShouldEqual, 1) 274 So(i, ShouldEqual, 1)
274 }) 275 })
275 276
276 }) 277 })
277 278
278 } 279 }
OLDNEW
« no previous file with comments | « impl/memory/gkvlite_iter.go ('k') | service/datastore/serialize/binary_tools.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698