Only pass CommitRequest to begin_streaming_parse
This commit is contained in:
@@ -499,12 +499,12 @@ TEST_CASE("CommitRequest streaming parsing") {
|
||||
while (offset < mutable_json.size() &&
|
||||
status == CommitRequestParser::ParseStatus::Incomplete) {
|
||||
size_t len = std::min(chunk_size, mutable_json.size() - offset);
|
||||
status = parser.parse_chunk(request, mutable_json.data() + offset, len);
|
||||
status = parser.parse_chunk(mutable_json.data() + offset, len);
|
||||
offset += len;
|
||||
}
|
||||
|
||||
if (status == CommitRequestParser::ParseStatus::Incomplete) {
|
||||
status = parser.finish_streaming_parse(request);
|
||||
status = parser.finish_streaming_parse();
|
||||
}
|
||||
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Complete);
|
||||
@@ -551,11 +551,11 @@ TEST_CASE("CommitRequest streaming parsing") {
|
||||
for (size_t i = 0; i < mutable_json.size() &&
|
||||
status == CommitRequestParser::ParseStatus::Incomplete;
|
||||
++i) {
|
||||
status = parser.parse_chunk(request, mutable_json.data() + i, 1);
|
||||
status = parser.parse_chunk(mutable_json.data() + i, 1);
|
||||
}
|
||||
|
||||
if (status == CommitRequestParser::ParseStatus::Incomplete) {
|
||||
status = parser.finish_streaming_parse(request);
|
||||
status = parser.finish_streaming_parse();
|
||||
}
|
||||
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Complete);
|
||||
@@ -593,10 +593,10 @@ TEST_CASE("CommitRequest streaming parsing") {
|
||||
|
||||
std::string mutable_json = invalid_json;
|
||||
CommitRequestParser::ParseStatus status =
|
||||
parser.parse_chunk(request, mutable_json.data(), mutable_json.size());
|
||||
parser.parse_chunk(mutable_json.data(), mutable_json.size());
|
||||
|
||||
if (status == CommitRequestParser::ParseStatus::Incomplete) {
|
||||
status = parser.finish_streaming_parse(request);
|
||||
status = parser.finish_streaming_parse();
|
||||
}
|
||||
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Error);
|
||||
@@ -610,14 +610,14 @@ TEST_CASE("CommitRequest streaming parsing") {
|
||||
|
||||
std::string mutable_json = json;
|
||||
CommitRequestParser::ParseStatus status =
|
||||
parser.parse_chunk(request, mutable_json.data(), mutable_json.size());
|
||||
parser.parse_chunk(mutable_json.data(), mutable_json.size());
|
||||
|
||||
// Should still be incomplete (streaming parser doesn't know if more data is
|
||||
// coming)
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Incomplete);
|
||||
|
||||
// Signal end of input to complete parsing
|
||||
status = parser.finish_streaming_parse(request);
|
||||
status = parser.finish_streaming_parse();
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Complete);
|
||||
REQUIRE(request.leader_id() == "test");
|
||||
REQUIRE(request.read_version() == 123);
|
||||
@@ -630,10 +630,10 @@ TEST_CASE("CommitRequest streaming parsing") {
|
||||
|
||||
std::string mutable_json = json;
|
||||
CommitRequestParser::ParseStatus status =
|
||||
parser.parse_chunk(request, mutable_json.data(), mutable_json.size());
|
||||
parser.parse_chunk(mutable_json.data(), mutable_json.size());
|
||||
|
||||
if (status == CommitRequestParser::ParseStatus::Incomplete) {
|
||||
status = parser.finish_streaming_parse(request);
|
||||
status = parser.finish_streaming_parse();
|
||||
}
|
||||
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Complete);
|
||||
@@ -648,10 +648,10 @@ TEST_CASE("CommitRequest streaming parsing") {
|
||||
|
||||
std::string mutable_json = json;
|
||||
CommitRequestParser::ParseStatus status =
|
||||
parser.parse_chunk(request, mutable_json.data(), mutable_json.size());
|
||||
parser.parse_chunk(mutable_json.data(), mutable_json.size());
|
||||
|
||||
if (status == CommitRequestParser::ParseStatus::Incomplete) {
|
||||
status = parser.finish_streaming_parse(request);
|
||||
status = parser.finish_streaming_parse();
|
||||
}
|
||||
|
||||
REQUIRE(status == CommitRequestParser::ParseStatus::Complete);
|
||||
@@ -837,4 +837,4 @@ TEST_CASE("CommitRequest arena debug dump") {
|
||||
REQUIRE(content_str.find("0x00") !=
|
||||
std::string::npos); // Should have hex addresses
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user