| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 cmpbin.WriteString(buf, "nerp") | 167 cmpbin.WriteString(buf, "nerp") |
| 168 So(string(ToBytes(mp("nerp"))), | 168 So(string(ToBytes(mp("nerp"))), |
| 169 ShouldEqual, buf.String()) | 169 ShouldEqual, buf.String()) |
| 170 }) | 170 }) |
| 171 | 171 |
| 172 Convey("Time", func() { | 172 Convey("Time", func() { |
| 173 tp := mp(time.Now().UTC()) | 173 tp := mp(time.Now().UTC()) |
| 174 So(string(ToBytes(tp.Value())), ShouldEqual, string(ToBy
tes(tp)[1:])) | 174 So(string(ToBytes(tp.Value())), ShouldEqual, string(ToBy
tes(tp)[1:])) |
| 175 }) | 175 }) |
| 176 | 176 |
| 177 Convey("Zero time", func() { |
| 178 buf := mkBuf(nil) |
| 179 So(WriteTime(buf, time.Time{}), ShouldBeNil) |
| 180 t, err := ReadTime(mkBuf(buf.Bytes())) |
| 181 So(err, ShouldBeNil) |
| 182 So(t.IsZero(), ShouldBeTrue) |
| 183 }) |
| 184 |
| 177 Convey("Bad ToBytes", func() { | 185 Convey("Bad ToBytes", func() { |
| 178 So(func() { ToBytes(100.7) }, ShouldPanic) | 186 So(func() { ToBytes(100.7) }, ShouldPanic) |
| 179 So(func() { ToBytesWithContext(100.7) }, ShouldPanic) | 187 So(func() { ToBytesWithContext(100.7) }, ShouldPanic) |
| 180 }) | 188 }) |
| 181 | 189 |
| 182 Convey("ReadKey", func() { | 190 Convey("ReadKey", func() { |
| 183 Convey("good cases", func() { | 191 Convey("good cases", func() { |
| 184 Convey("w/ ctx decodes normally w/ ctx", func()
{ | 192 Convey("w/ ctx decodes normally w/ ctx", func()
{ |
| 185 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) | 193 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) |
| 186 data := ToBytesWithContext(k) | 194 data := ToBytesWithContext(k) |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 for i := 0; i < MaxIndexColumns+1; i++ { | 453 for i := 0; i < MaxIndexColumns+1; i++ { |
| 446 id.SortBy = append(id.SortBy, ds.IndexCo
lumn{Property: "Hi", Direction: ds.ASCENDING}) | 454 id.SortBy = append(id.SortBy, ds.IndexCo
lumn{Property: "Hi", Direction: ds.ASCENDING}) |
| 447 } | 455 } |
| 448 data := ToBytes(*id.PrepForIdxTable()) | 456 data := ToBytes(*id.PrepForIdxTable()) |
| 449 newID, err = ReadIndexDefinition(mkBuf(data)) | 457 newID, err = ReadIndexDefinition(mkBuf(data)) |
| 450 So(err, ShouldErrLike, "over 64 sort orders") | 458 So(err, ShouldErrLike, "over 64 sort orders") |
| 451 }) | 459 }) |
| 452 }) | 460 }) |
| 453 }) | 461 }) |
| 454 } | 462 } |
| OLD | NEW |