| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |