Don*_*aka 5 c++ protocol-buffers proto
我必须检查我的程序(C++)的两个 protobuf 消息之间的差异。我正在尝试MessageDifferencer::Compare和MessageDifferencer::Equals。
我map在原始消息中有一个字段,据我们所知,不能保证该字段是有序的。所以我想知道大家MessageDifferencer对此有何看法?是否有人Compare或Equals职能部门可以处理此案?
我的意思是,如果映射未排序,我们如何确定第一条消息中的所有元素都与第二条消息中的正确元素进行了比较?
我的消息是这样的:
message foo
{
// some-fields
map<string, int64> bar = 2;
// more-fields
}
Run Code Online (Sandbox Code Playgroud)
我对 C++ 和 protobuf 都很陌生,所以任何正确方向的想法都会有所帮助。
更新:
即使我比较相同的消息,它也显示不匹配,我可以在差异报告中看到这是因为同一字段没有相互匹配。
来自 protobuf文档:
Wire format ordering and map iteration ordering of map values is undefined, so you cannot rely on your map items being in a particular order.
Run Code Online (Sandbox Code Playgroud)