[Yunq] Add basic test for repeated fields.
This commit is contained in:
parent
65e9fa1767
commit
27c39d05e8
5 changed files with 80 additions and 1 deletions
|
|
@ -136,6 +136,43 @@ uint64_t Cap::SerializeInternal(yunq::Serializer& serializer) const {
|
|||
|
||||
return serializer.size();
|
||||
}
|
||||
glcr::Status Repeated::ParseFromBytes(const yunq::MessageView& message) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status Repeated::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status Repeated::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||
RETURN_ERROR(message.CheckHeader());
|
||||
// Parse unsigned_ints.
|
||||
ASSIGN_OR_RETURN(unsigned_ints_, message.ReadRepeated<uint64_t>(0));
|
||||
|
||||
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
uint64_t Repeated::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t Repeated::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t Repeated::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write unsigned_ints.
|
||||
serializer.WriteRepeated<uint64_t>(0, unsigned_ints_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
}
|
||||
|
||||
|
||||
} // namepace ex
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue