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 serialize | 5 package serialize |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "io" | 10 "io" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 Convey("Time", func() { | 183 Convey("Time", func() { |
184 tp := mp(time.Now().UTC()) | 184 tp := mp(time.Now().UTC()) |
185 So(string(ToBytes(tp.Value())), ShouldEqual, string(ToBy
tes(tp)[1:])) | 185 So(string(ToBytes(tp.Value())), ShouldEqual, string(ToBy
tes(tp)[1:])) |
186 }) | 186 }) |
187 | 187 |
188 Convey("Zero time", func() { | 188 Convey("Zero time", func() { |
189 buf := mkBuf(nil) | 189 buf := mkBuf(nil) |
190 So(WriteTime(buf, time.Time{}), ShouldBeNil) | 190 So(WriteTime(buf, time.Time{}), ShouldBeNil) |
191 t, err := ReadTime(mkBuf(buf.Bytes())) | 191 t, err := ReadTime(mkBuf(buf.Bytes())) |
192 So(err, ShouldBeNil) | 192 So(err, ShouldBeNil) |
193 » » » So(t.IsZero(), ShouldBeTrue) | 193 » » » So(t, ShouldResemble, time.Time{}) |
194 }) | 194 }) |
195 | 195 |
196 Convey("Bad ToBytes", func() { | 196 Convey("Bad ToBytes", func() { |
197 So(func() { ToBytes(100.7) }, ShouldPanic) | 197 So(func() { ToBytes(100.7) }, ShouldPanic) |
198 So(func() { ToBytesWithContext(100.7) }, ShouldPanic) | 198 So(func() { ToBytesWithContext(100.7) }, ShouldPanic) |
199 }) | 199 }) |
200 | 200 |
201 Convey("ReadKey", func() { | 201 Convey("ReadKey", func() { |
202 Convey("good cases", func() { | 202 Convey("good cases", func() { |
203 Convey("w/ ctx decodes normally w/ ctx", func()
{ | 203 Convey("w/ ctx decodes normally w/ ctx", func()
{ |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 for i := 0; i < MaxIndexColumns+1; i++ { | 465 for i := 0; i < MaxIndexColumns+1; i++ { |
466 id.SortBy = append(id.SortBy, ds.IndexCo
lumn{Property: "Hi", Descending: true}) | 466 id.SortBy = append(id.SortBy, ds.IndexCo
lumn{Property: "Hi", Descending: true}) |
467 } | 467 } |
468 data := ToBytes(*id.PrepForIdxTable()) | 468 data := ToBytes(*id.PrepForIdxTable()) |
469 newID, err = ReadIndexDefinition(mkBuf(data)) | 469 newID, err = ReadIndexDefinition(mkBuf(data)) |
470 So(err, ShouldErrLike, "over 64 sort orders") | 470 So(err, ShouldErrLike, "over 64 sort orders") |
471 }) | 471 }) |
472 }) | 472 }) |
473 }) | 473 }) |
474 } | 474 } |
OLD | NEW |