OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "courgette/streams.h" | 5 #include "courgette/streams.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 courgette::SinkStream collected; | 168 courgette::SinkStream collected; |
169 out.CopyTo(&collected); | 169 out.CopyTo(&collected); |
170 courgette::SourceStreamSet in; | 170 courgette::SourceStreamSet in; |
171 bool can_init_in = in.Init(collected.Buffer(), collected.Length()); | 171 bool can_init_in = in.Init(collected.Buffer(), collected.Length()); |
172 EXPECT_EQ(true, can_init_in); | 172 EXPECT_EQ(true, can_init_in); |
173 | 173 |
174 courgette::SourceStreamSet subset1; | 174 courgette::SourceStreamSet subset1; |
175 bool can_read_1 = in.ReadSet(&subset1); | 175 bool can_read_1 = in.ReadSet(&subset1); |
176 EXPECT_EQ(true, can_read_1); | 176 EXPECT_EQ(true, can_read_1); |
177 EXPECT_EQ(false, in.Empty()); | 177 EXPECT_FALSE(in.Empty()); |
178 | 178 |
179 courgette::SourceStreamSet subset2; | 179 courgette::SourceStreamSet subset2; |
180 bool can_read_2 = in.ReadSet(&subset2); | 180 bool can_read_2 = in.ReadSet(&subset2); |
181 EXPECT_EQ(true, can_read_2); | 181 EXPECT_EQ(true, can_read_2); |
182 EXPECT_EQ(true, in.Empty()); | 182 EXPECT_EQ(true, in.Empty()); |
183 | 183 |
184 courgette::SourceStreamSet subset3; | 184 courgette::SourceStreamSet subset3; |
185 bool can_read_3 = in.ReadSet(&subset3); | 185 bool can_read_3 = in.ReadSet(&subset3); |
186 EXPECT_EQ(false, can_read_3); | 186 EXPECT_FALSE(can_read_3); |
187 | 187 |
188 EXPECT_EQ(false, subset1.Empty()); | 188 EXPECT_FALSE(subset1.Empty()); |
189 EXPECT_EQ(false, subset1.Empty()); | 189 EXPECT_FALSE(subset1.Empty()); |
190 | 190 |
191 uint32 datum; | 191 uint32 datum; |
192 EXPECT_EQ(true, subset1.stream(3)->ReadVarint32(&datum)); | 192 EXPECT_EQ(true, subset1.stream(3)->ReadVarint32(&datum)); |
193 EXPECT_EQ(30000U, datum); | 193 EXPECT_EQ(30000U, datum); |
194 EXPECT_EQ(true, subset1.stream(5)->ReadVarint32(&datum)); | 194 EXPECT_EQ(true, subset1.stream(5)->ReadVarint32(&datum)); |
195 EXPECT_EQ(50000U, datum); | 195 EXPECT_EQ(50000U, datum); |
196 EXPECT_EQ(true, subset1.Empty()); | 196 EXPECT_EQ(true, subset1.Empty()); |
197 | 197 |
198 EXPECT_EQ(true, subset2.stream(2)->ReadVarint32(&datum)); | 198 EXPECT_EQ(true, subset2.stream(2)->ReadVarint32(&datum)); |
199 EXPECT_EQ(20000U, datum); | 199 EXPECT_EQ(20000U, datum); |
200 EXPECT_EQ(true, subset2.stream(6)->ReadVarint32(&datum)); | 200 EXPECT_EQ(true, subset2.stream(6)->ReadVarint32(&datum)); |
201 EXPECT_EQ(60000U, datum); | 201 EXPECT_EQ(60000U, datum); |
202 EXPECT_EQ(true, subset2.Empty()); | 202 EXPECT_EQ(true, subset2.Empty()); |
203 } | 203 } |
OLD | NEW |