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

Side by Side Diff: service/datastore/types_test.go

Issue 2011773002: datastore: variadic Get, Put, Exists, Delete. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: s/chn/chan/ Created 4 years, 6 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/types.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package datastore
6
7 import (
8 "testing"
9
10 . "github.com/smartystreets/goconvey/convey"
11 )
12
13 func TestExistsResult(t *testing.T) {
14 t.Parallel()
15
16 Convey(`Testing ExistsResult`, t, func() {
17 var er ExistsResult
18
19 Convey(`With no elements`, func() {
20 er.init()
21
22 So(er.All(), ShouldBeTrue)
23 So(er.Any(), ShouldBeFalse)
24 So(er.List(), ShouldResemble, BoolList{})
25 })
26
27 Convey(`With single-tier elements`, func() {
28 er.init(1, 1, 1, 1)
29
30 So(er.All(), ShouldBeFalse)
31 So(er.Any(), ShouldBeFalse)
32 So(er.List(), ShouldResemble, BoolList{false, false, fal se, false})
33
34 er.set(0, 0)
35 er.set(2, 0)
36
37 So(er.All(), ShouldBeFalse)
38 So(er.Any(), ShouldBeTrue)
39 So(er.List(), ShouldResemble, BoolList{true, false, true , false})
40 So(er.List(0), ShouldResemble, BoolList{true})
41 So(er.Get(0, 0), ShouldBeTrue)
42 So(er.List(1), ShouldResemble, BoolList{false})
43 So(er.Get(1, 0), ShouldBeFalse)
44 So(er.List(2), ShouldResemble, BoolList{true})
45 So(er.Get(2, 0), ShouldBeTrue)
46 So(er.List(3), ShouldResemble, BoolList{false})
47 So(er.Get(3, 0), ShouldBeFalse)
48 })
49
50 Convey(`With combined single- and multi-tier elements`, func() {
51 er.init(1, 0, 3, 2)
52
53 So(er.All(), ShouldBeFalse)
54 So(er.Any(), ShouldBeFalse)
55 So(er.List(), ShouldResemble, BoolList{false, false, fal se, false})
56
57 // Set everything except (2, 1).
58 er.set(0, 0)
59 er.set(2, 0)
60 er.set(2, 2)
61 er.set(3, 0)
62 er.set(3, 1)
63
64 er.updateSlices()
65 So(er.All(), ShouldBeFalse)
66 So(er.Any(), ShouldBeTrue)
67 So(er.List(), ShouldResemble, BoolList{true, true, false , true})
68 So(er.List(0), ShouldResemble, BoolList{true})
69 So(er.List(1), ShouldResemble, BoolList(nil))
70 So(er.List(2), ShouldResemble, BoolList{true, false, tru e})
71 So(er.Get(2, 0), ShouldBeTrue)
72 So(er.Get(2, 1), ShouldBeFalse)
73 So(er.List(3), ShouldResemble, BoolList{true, true})
74
75 // Set the missing boolean.
76 er.set(2, 1)
77 er.updateSlices()
78 So(er.All(), ShouldBeTrue)
79 })
80
81 Convey(`Zero-length slices are handled properly.`, func() {
82 er.init(1, 0, 0, 1)
83
84 er.updateSlices()
85 So(er.List(), ShouldResemble, BoolList{false, true, true , false})
86 So(er.All(), ShouldBeFalse)
87 So(er.Any(), ShouldBeFalse)
88
89 er.set(0, 0)
90 er.updateSlices()
91 So(er.List(), ShouldResemble, BoolList{true, true, true, false})
92 So(er.All(), ShouldBeFalse)
93 So(er.Any(), ShouldBeTrue)
94
95 er.set(3, 0)
96 er.updateSlices()
97 So(er.List(), ShouldResemble, BoolList{true, true, true, true})
98 So(er.All(), ShouldBeTrue)
99 So(er.Any(), ShouldBeTrue)
100 })
101 })
102 }
OLDNEW
« no previous file with comments | « service/datastore/types.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698