Updated bundled protozero to v1.7.0

This commit is contained in:
Denis Chaplygin
2020-10-16 10:25:52 +03:00
parent df3ed43d70
commit a8362d75b5
126 changed files with 18489 additions and 11079 deletions
@@ -1,3 +1,4 @@
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
@@ -1,8 +1,9 @@
#include <testcase.hpp>
#include "testcase.pb.h"
int main(int c, char *argv[]) {
int main() {
TestRepeatedPackedFixed32::Test msg;
write_to_file(msg, "data-empty.pbf");
@@ -1,35 +1,39 @@
#include <test.hpp>
#include <buffer.hpp>
#include <array>
#include <sstream>
#include "t/repeated_packed_fixed32/repeated_packed_fixed32_testcase.pb.h"
TEST_CASE("write repeated packed fixed32 field and check with libprotobuf") {
TEMPLATE_TEST_CASE("write repeated packed fixed32 field and check with libprotobuf", "",
buffer_test_string, buffer_test_vector, buffer_test_array, buffer_test_external) {
std::string buffer;
protozero::pbf_writer pw{buffer};
TestType buffer;
typename TestType::writer_type pw{buffer.buffer()};
TestRepeatedPackedFixed32::Test msg;
SECTION("empty") {
uint32_t data[] = { 17UL };
const std::array<uint32_t, 1> data = {{ 17UL }};
pw.add_packed_fixed32(1, std::begin(data), std::begin(data) /* !!!! */);
}
SECTION("one") {
uint32_t data[] = { 17UL };
const std::array<uint32_t, 1> data = {{ 17UL }};
pw.add_packed_fixed32(1, std::begin(data), std::end(data));
msg.ParseFromString(buffer);
msg.ParseFromArray(buffer.data(), buffer.size());
REQUIRE(msg.i().size() == 1);
REQUIRE(msg.i(0) == 17UL);
}
SECTION("many") {
uint32_t data[] = { 17UL, 0UL, 1UL, std::numeric_limits<uint32_t>::max() };
const std::array<uint32_t, 4> data = {{ 17UL, 0UL, 1UL, std::numeric_limits<uint32_t>::max() }};
pw.add_packed_fixed32(1, std::begin(data), std::end(data));
msg.ParseFromString(buffer);
msg.ParseFromArray(buffer.data(), buffer.size());
REQUIRE(msg.i().size() == 4);
REQUIRE(msg.i(0) == 17UL);
@@ -39,17 +43,18 @@ TEST_CASE("write repeated packed fixed32 field and check with libprotobuf") {
}
}
TEST_CASE("write from different types of iterators and check with libprotobuf") {
TEMPLATE_TEST_CASE("write from different types of iterators and check with libprotobuf", "",
buffer_test_string, buffer_test_vector, buffer_test_array, buffer_test_external) {
std::string buffer;
protozero::pbf_writer pw{buffer};
TestType buffer;
typename TestType::writer_type pw{buffer.buffer()};
TestRepeatedPackedFixed32::Test msg;
SECTION("from uint16_t") {
uint16_t data[] = { 1, 4, 9, 16, 25 };
const std::array<uint16_t, 5> data = {{ 1, 4, 9, 16, 25 }};
pw.add_packed_fixed32(1, std::begin(data), std::end(data));
pw.template add_packed_fixed<uint32_t>(1, std::begin(data), std::end(data));
}
SECTION("from string") {
@@ -59,10 +64,10 @@ TEST_CASE("write from different types of iterators and check with libprotobuf")
std::istream_iterator<uint32_t> eod;
std::istream_iterator<uint32_t> it(sdata);
pw.add_packed_fixed32(1, it, eod);
pw.template add_packed_fixed<uint32_t>(1, it, eod);
}
msg.ParseFromString(buffer);
msg.ParseFromArray(buffer.data(), buffer.size());
REQUIRE(msg.i().size() == 5);
REQUIRE(msg.i(0) == 1);