Lines Matching refs:proto

29 static std::string flushToString(ProtoOutputStream* proto) {  in flushToString()  argument
34 EXPECT_TRUE(proto->flush(tf.fd)); in flushToString()
39 static std::string iterateToString(ProtoOutputStream* proto) { in iterateToString() argument
41 content.reserve(proto->size()); in iterateToString()
42 sp<ProtoReader> reader = proto->data(); in iterateToString()
53 ProtoOutputStream proto; in TEST() local
54 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | PrimitiveProto::kValInt32FieldNumber, 123)); in TEST()
55 EXPECT_TRUE(proto.write(FIELD_TYPE_INT64 | PrimitiveProto::kValInt64FieldNumber, -1LL)); in TEST()
56 EXPECT_TRUE(proto.write(FIELD_TYPE_FLOAT | PrimitiveProto::kValFloatFieldNumber, -23.5f)); in TEST()
57 EXPECT_TRUE(proto.write(FIELD_TYPE_DOUBLE | PrimitiveProto::kValDoubleFieldNumber, 324.5)); in TEST()
58 EXPECT_TRUE(proto.write(FIELD_TYPE_UINT32 | PrimitiveProto::kValUint32FieldNumber, 3424)); in TEST()
59 EXPECT_TRUE(proto.write(FIELD_TYPE_UINT64 | PrimitiveProto::kValUint64FieldNumber, 57LL)); in TEST()
60 EXPECT_TRUE(proto.write(FIELD_TYPE_FIXED32 | PrimitiveProto::kValFixed32FieldNumber, -20)); in TEST()
61 EXPECT_TRUE(proto.write(FIELD_TYPE_FIXED64 | PrimitiveProto::kValFixed64FieldNumber, -37LL)); in TEST()
62 EXPECT_TRUE(proto.write(FIELD_TYPE_BOOL | PrimitiveProto::kValBoolFieldNumber, true)); in TEST()
63 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | PrimitiveProto::kValStringFieldNumber, s)); in TEST()
64 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | PrimitiveProto::kValBytesFieldNumber, b, 5)); in TEST()
65 EXPECT_TRUE(proto.write(FIELD_TYPE_SFIXED32 | PrimitiveProto::kValSfixed32FieldNumber, 63)); in TEST()
66 EXPECT_TRUE(proto.write(FIELD_TYPE_SFIXED64 | PrimitiveProto::kValSfixed64FieldNumber, -54)); in TEST()
67 EXPECT_TRUE(proto.write(FIELD_TYPE_SINT32 | PrimitiveProto::kValSint32FieldNumber, -533)); in TEST()
68 …EXPECT_TRUE(proto.write(FIELD_TYPE_SINT64 | PrimitiveProto::kValSint64FieldNumber, -61224762453LL)… in TEST()
69 EXPECT_TRUE(proto.write(FIELD_TYPE_ENUM | PrimitiveProto::kValEnumFieldNumber, 2)); in TEST()
72 ASSERT_TRUE(primitives.ParseFromString(flushToString(&proto))); in TEST()
95 ProtoOutputStream proto; in TEST() local
96 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | PrimitiveProto::kValInt32FieldNumber, 123)); in TEST()
97 EXPECT_TRUE(proto.write(FIELD_TYPE_INT64 | PrimitiveProto::kValInt64FieldNumber, -1LL)); in TEST()
98 EXPECT_TRUE(proto.write(FIELD_TYPE_FLOAT | PrimitiveProto::kValFloatFieldNumber, -23.5f)); in TEST()
99 EXPECT_TRUE(proto.write(FIELD_TYPE_DOUBLE | PrimitiveProto::kValDoubleFieldNumber, 324.5)); in TEST()
100 EXPECT_TRUE(proto.write(FIELD_TYPE_UINT32 | PrimitiveProto::kValUint32FieldNumber, 3424)); in TEST()
101 EXPECT_TRUE(proto.write(FIELD_TYPE_UINT64 | PrimitiveProto::kValUint64FieldNumber, 57LL)); in TEST()
102 EXPECT_TRUE(proto.write(FIELD_TYPE_FIXED32 | PrimitiveProto::kValFixed32FieldNumber, -20)); in TEST()
103 EXPECT_TRUE(proto.write(FIELD_TYPE_FIXED64 | PrimitiveProto::kValFixed64FieldNumber, -37LL)); in TEST()
104 EXPECT_TRUE(proto.write(FIELD_TYPE_BOOL | PrimitiveProto::kValBoolFieldNumber, true)); in TEST()
105 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | PrimitiveProto::kValStringFieldNumber, s)); in TEST()
106 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | PrimitiveProto::kValBytesFieldNumber, b, 5)); in TEST()
107 EXPECT_TRUE(proto.write(FIELD_TYPE_SFIXED32 | PrimitiveProto::kValSfixed32FieldNumber, 63)); in TEST()
108 EXPECT_TRUE(proto.write(FIELD_TYPE_SFIXED64 | PrimitiveProto::kValSfixed64FieldNumber, -54)); in TEST()
109 EXPECT_TRUE(proto.write(FIELD_TYPE_SINT32 | PrimitiveProto::kValSint32FieldNumber, -533)); in TEST()
110 …EXPECT_TRUE(proto.write(FIELD_TYPE_SINT64 | PrimitiveProto::kValSint64FieldNumber, -61224762453LL)… in TEST()
111 EXPECT_TRUE(proto.write(FIELD_TYPE_ENUM | PrimitiveProto::kValEnumFieldNumber, 2)); in TEST()
115 ASSERT_TRUE(proto.serializeToString(&serialized)); in TEST()
139 ProtoOutputStream proto; in TEST() local
140 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | PrimitiveProto::kValInt32FieldNumber, 123)); in TEST()
141 EXPECT_TRUE(proto.write(FIELD_TYPE_INT64 | PrimitiveProto::kValInt64FieldNumber, -1LL)); in TEST()
142 EXPECT_TRUE(proto.write(FIELD_TYPE_FLOAT | PrimitiveProto::kValFloatFieldNumber, -23.5f)); in TEST()
143 EXPECT_TRUE(proto.write(FIELD_TYPE_DOUBLE | PrimitiveProto::kValDoubleFieldNumber, 324.5)); in TEST()
144 EXPECT_TRUE(proto.write(FIELD_TYPE_UINT32 | PrimitiveProto::kValUint32FieldNumber, 3424)); in TEST()
145 EXPECT_TRUE(proto.write(FIELD_TYPE_UINT64 | PrimitiveProto::kValUint64FieldNumber, 57LL)); in TEST()
146 EXPECT_TRUE(proto.write(FIELD_TYPE_FIXED32 | PrimitiveProto::kValFixed32FieldNumber, -20)); in TEST()
147 EXPECT_TRUE(proto.write(FIELD_TYPE_FIXED64 | PrimitiveProto::kValFixed64FieldNumber, -37LL)); in TEST()
148 EXPECT_TRUE(proto.write(FIELD_TYPE_BOOL | PrimitiveProto::kValBoolFieldNumber, true)); in TEST()
149 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | PrimitiveProto::kValStringFieldNumber, s)); in TEST()
150 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | PrimitiveProto::kValBytesFieldNumber, b, 5)); in TEST()
151 EXPECT_TRUE(proto.write(FIELD_TYPE_SFIXED32 | PrimitiveProto::kValSfixed32FieldNumber, 63)); in TEST()
152 EXPECT_TRUE(proto.write(FIELD_TYPE_SFIXED64 | PrimitiveProto::kValSfixed64FieldNumber, -54)); in TEST()
153 EXPECT_TRUE(proto.write(FIELD_TYPE_SINT32 | PrimitiveProto::kValSint32FieldNumber, -533)); in TEST()
154 …EXPECT_TRUE(proto.write(FIELD_TYPE_SINT64 | PrimitiveProto::kValSint64FieldNumber, -61224762453LL)… in TEST()
155 EXPECT_TRUE(proto.write(FIELD_TYPE_ENUM | PrimitiveProto::kValEnumFieldNumber, 2)); in TEST()
159 ASSERT_TRUE(proto.serializeToVector(&vec)); in TEST()
188 ProtoOutputStream proto; in TEST() local
189 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 23)); in TEST()
190 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 101)); in TEST()
191 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, -72)); in TEST()
192 uint64_t token1 = proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
193 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 12)); in TEST()
194 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | ComplexProto::Log::kNameFieldNumber, name1)); in TEST()
196 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | ComplexProto::Log::kDataFieldNumber, data1, 5)); in TEST()
197 proto.end(token1); in TEST()
198 uint64_t token2 = proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
199 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 98)); in TEST()
200 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | ComplexProto::Log::kNameFieldNumber, name2)); in TEST()
201 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | ComplexProto::Log::kDataFieldNumber, data2, 4)); in TEST()
202 proto.end(token2); in TEST()
205 ASSERT_TRUE(complex.ParseFromString(iterateToString(&proto))); in TEST()
227 ProtoOutputStream proto; in TEST() local
228 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 23)); in TEST()
229 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 101)); in TEST()
230 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, -72)); in TEST()
231 uint64_t token1 = proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
232 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 12)); in TEST()
233 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | ComplexProto::Log::kNameFieldNumber, name1)); in TEST()
235 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | ComplexProto::Log::kDataFieldNumber, data1, 5)); in TEST()
236 proto.end(token1); in TEST()
237 uint64_t token2 = proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
238 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 98)); in TEST()
239 EXPECT_TRUE(proto.write(FIELD_TYPE_STRING | ComplexProto::Log::kNameFieldNumber, name2)); in TEST()
240 EXPECT_TRUE(proto.write(FIELD_TYPE_BYTES | ComplexProto::Log::kDataFieldNumber, data2, 4)); in TEST()
241 proto.end(token2); in TEST()
245 ASSERT_TRUE(proto.serializeToString(&serialized)); in TEST()
263 ProtoOutputStream proto; in TEST() local
264 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 32)); in TEST()
265 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 15)); in TEST()
266 EXPECT_EQ(proto.bytesWritten(), 4); in TEST()
267 EXPECT_EQ(proto.size(), 4); in TEST()
269 EXPECT_FALSE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 94)); in TEST()
272 ASSERT_TRUE(beforeClear.ParseFromString(flushToString(&proto))); in TEST()
277 proto.clear(); in TEST()
278 EXPECT_EQ(proto.bytesWritten(), 0); in TEST()
279 EXPECT_TRUE(proto.write(FIELD_TYPE_INT32 | ComplexProto::kIntsFieldNumber, 1076)); in TEST()
282 ASSERT_TRUE(afterClear.ParseFromString(flushToString(&proto))); in TEST()
288 ProtoOutputStream proto; in TEST() local
289 proto.writeRawVarint((ComplexProto::kIntsFieldNumber << FIELD_ID_SHIFT) + WIRE_TYPE_VARINT); in TEST()
290 proto.writeRawVarint(UINT64_C(-123809234)); in TEST()
291 proto.writeLengthDelimitedHeader(ComplexProto::kLogsFieldNumber, 8); in TEST()
292proto.writeRawByte((ComplexProto::Log::kDataFieldNumber << FIELD_ID_SHIFT) + WIRE_TYPE_LENGTH_DELI… in TEST()
293 proto.writeRawByte(6); in TEST()
294 proto.writeRawByte('b'); in TEST()
295 proto.writeRawByte('a'); in TEST()
296 proto.writeRawByte('n'); in TEST()
297 proto.writeRawByte('a'); in TEST()
298 proto.writeRawByte('n'); in TEST()
299 proto.writeRawByte('a'); in TEST()
300 uint64_t token = proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
301 proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 14); in TEST()
302 proto.end(token); in TEST()
305 ASSERT_TRUE(complex.ParseFromString(flushToString(&proto))); in TEST()
320 ProtoOutputStream proto; in TEST() local
321 EXPECT_FALSE(proto.write(FIELD_TYPE_UNKNOWN | PrimitiveProto::kValInt32FieldNumber, 790)); in TEST()
322 EXPECT_FALSE(proto.write(FIELD_TYPE_ENUM | PrimitiveProto::kValEnumFieldNumber, 234.34)); in TEST()
323 EXPECT_FALSE(proto.write(FIELD_TYPE_BOOL | PrimitiveProto::kValBoolFieldNumber, 18.73f)); in TEST()
324 EXPECT_EQ(proto.size(), 0); in TEST()
328 ProtoOutputStream proto; in TEST() local
329 proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
330 proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 53); in TEST()
332 EXPECT_NE(proto.bytesWritten(), 0); in TEST()
333 EXPECT_EQ(proto.size(), 0); in TEST()
334 EXPECT_FALSE(proto.flush(STDOUT_FILENO)); in TEST()
339 ProtoOutputStream proto; in TEST() local
340 uint64_t token = proto.start(FIELD_TYPE_MESSAGE | ComplexProto::kLogsFieldNumber); in TEST()
341 proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 53); in TEST()
342 proto.end(token); in TEST()
343 proto.end(token); in TEST()
344 EXPECT_NE(proto.bytesWritten(), 0); in TEST()
345 EXPECT_EQ(proto.size(), 0); in TEST()
346 EXPECT_FALSE(proto.flush(STDOUT_FILENO)); in TEST()
350 ProtoOutputStream proto; in TEST() local
353 proto.write(FIELD_TYPE_INT32 | ComplexProto::Log::kIdFieldNumber, 53); in TEST()
354 proto.end(wrongToken); in TEST()
355 EXPECT_NE(proto.bytesWritten(), 0); in TEST()
356 EXPECT_EQ(proto.size(), 0); in TEST()
357 EXPECT_FALSE(proto.flush(STDOUT_FILENO)); in TEST()