aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/arena_test_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/arena_test_util.h')
-rw-r--r--src/google/protobuf/arena_test_util.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/google/protobuf/arena_test_util.h b/src/google/protobuf/arena_test_util.h
index 9c821b90..fdbaca06 100644
--- a/src/google/protobuf/arena_test_util.h
+++ b/src/google/protobuf/arena_test_util.h
@@ -33,6 +33,8 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/arena.h>
namespace google {
@@ -41,7 +43,15 @@ namespace protobuf {
template <typename T, bool use_arena>
void TestParseCorruptedString(const T& message) {
int success_count = 0;
- string s = message.SerializeAsString();
+ std::string s;
+ {
+ // Map order is not deterministic. To make the test deterministic we want
+ // to serialize the proto deterministically.
+ io::StringOutputStream output(&s);
+ io::CodedOutputStream out(&output);
+ out.SetSerializationDeterministic(true);
+ message.SerializePartialToCodedStream(&out);
+ }
const int kMaxIters = 900;
const int stride = s.size() <= kMaxIters ? 1 : s.size() / kMaxIters;
const int start = stride == 1 || use_arena ? 0 : (stride + 1) / 2;