diff options
author | Josh Haberman <jhaberman@gmail.com> | 2013-10-24 12:43:19 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2013-10-24 12:43:19 -0700 |
commit | 26d98ca94f2f049e8767b4a9a33d185a3d7ea0fd (patch) | |
tree | 340bcf495f06ed05c9f3fb423f210caf4edce2b1 /tests/test_vs_proto2.cc | |
parent | 61109fca1f967771c21dc7184aee35f3b439c577 (diff) |
Merge from Google-internal development:
- rewritten decoder; interpreted decoder is bytecode-based,
JIT decoder no longer falls back to the interpreter.
- C++ improvements: C++11-compatible iterators, upb::reffed_ptr
for RAII refcounting, better upcast/downcast support.
- removed the gross upb_value abstraction from public upb.h.
Diffstat (limited to 'tests/test_vs_proto2.cc')
-rw-r--r-- | tests/test_vs_proto2.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/test_vs_proto2.cc b/tests/test_vs_proto2.cc index bc6df46..d766b42 100644 --- a/tests/test_vs_proto2.cc +++ b/tests/test_vs_proto2.cc @@ -12,6 +12,7 @@ #include <google/protobuf/descriptor.h> #include <google/protobuf/dynamic_message.h> #include <google/protobuf/message.h> +#include <google/protobuf/text_format.h> #include <google/protobuf/wire_format_lite.h> #include <inttypes.h> #include <stdint.h> @@ -24,14 +25,15 @@ #include "upb/handlers.h" #include "upb/pb/decoder.h" #include "upb/pb/glue.h" -#include "upb/pb/varint.h" +#include "upb/pb/varint.int.h" #include "upb_test.h" void compare_metadata(const google::protobuf::Descriptor* d, const upb::MessageDef *upb_md) { ASSERT(d->field_count() == upb_md->field_count()); - for (upb::MessageDef::ConstIterator i(upb_md); !i.Done(); i.Next()) { - const upb::FieldDef* upb_f = i.field(); + for (upb::MessageDef::const_iterator i = upb_md->begin(); i != upb_md->end(); + ++i) { + const upb::FieldDef* upb_f = *i; const google::protobuf::FieldDescriptor *proto2_f = d->FindFieldByNumber(upb_f->number()); ASSERT(upb_f); @@ -65,6 +67,9 @@ void parse_and_compare(google::protobuf::Message *msg1, msg2->Clear(); bool ok = upb::PutStringToBytestream(decoder_sink, str, len); + if (!ok) { + fprintf(stderr, "error parsing: %s\n", pipeline.status().GetString()); + } ASSERT(ok); ASSERT(pipeline.status().ok()); @@ -76,12 +81,21 @@ void parse_and_compare(google::protobuf::Message *msg1, std::string str2; msg1->SerializeToString(&str1); msg2->SerializeToString(&str2); + + std::string text_str1; + std::string text_str2; + google::protobuf::TextFormat::PrintToString(*msg1, &text_str1); + google::protobuf::TextFormat::PrintToString(*msg2, &text_str2); + if (str1 != str2) { + fprintf(stderr, "str1: %s, str2: %s\n", + text_str1.c_str(), text_str2.c_str()); + } ASSERT(str1 == str2); ASSERT(std::string(str, len) == str2); } void test_zig_zag() { - for (uint64_t num = 5; num * 1.5 > num; num *= 1.5) { + for (uint64_t num = 5; num * 1.5 < UINT64_MAX; num *= 1.5) { ASSERT(upb_zzenc_64(num) == google::protobuf::internal::WireFormatLite::ZigZagEncode64(num)); if (num < UINT32_MAX) { |