Updated bundled protozero to v1.7.0
This commit is contained in:
@@ -47,7 +47,7 @@ TEST_CASE("check alignment issues for fixed32 field") {
|
||||
for (std::string::size_type i = 1; i < abuffer.size() - n; ++i) {
|
||||
protozero::pbf_reader item{abuffer.data() + n, i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ TEST_CASE("check alignment issues for fixed32 field") {
|
||||
abuffer.append(load_data("fixed32/data-zero"));
|
||||
protozero::pbf_reader item{abuffer.data() + n, abuffer.size() - n};
|
||||
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), assert_error);
|
||||
REQUIRE(item.next());
|
||||
REQUIRE(item.get_fixed32() == 0UL);
|
||||
REQUIRE_THROWS(item.get_fixed32());
|
||||
@@ -66,7 +66,7 @@ TEST_CASE("check alignment issues for fixed32 field") {
|
||||
abuffer.append(load_data("fixed32/data-zero"));
|
||||
protozero::pbf_reader item{abuffer.data() + n, abuffer.size() - n};
|
||||
|
||||
REQUIRE_THROWS_AS(item.skip(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.skip(), assert_error);
|
||||
REQUIRE(item.next());
|
||||
item.skip();
|
||||
REQUIRE_THROWS(item.skip());
|
||||
@@ -114,7 +114,7 @@ TEST_CASE("check alignment issues for fixed64 field") {
|
||||
for (std::string::size_type i = 1; i < abuffer.size() - n; ++i) {
|
||||
protozero::pbf_reader item{abuffer.data() + n, i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ TEST_CASE("write bool field using moved pbf_builder") {
|
||||
|
||||
protozero::pbf_builder<TestBoolean::Test> pw{std::move(pw2)};
|
||||
REQUIRE(pw.valid());
|
||||
REQUIRE_FALSE(pw2.valid()); // NOLINT(hicpp-invalid-access-moved, bugprone-use-after-move)
|
||||
REQUIRE_FALSE(pw2.valid()); // NOLINT(hicpp-invalid-access-moved, bugprone-use-after-move, clang-analyzer-cplusplus.Move)
|
||||
|
||||
SECTION("false") {
|
||||
pw.add_bool(TestBoolean::Test::required_bool_b, false);
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestBoolean::Test msg;
|
||||
|
||||
msg.set_b(0);
|
||||
|
||||
+7
-6
@@ -1,21 +1,22 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <test.hpp> // IWYU pragma: keep
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/bool/bool_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write bool field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write bool 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()};
|
||||
|
||||
TestBoolean::Test msg;
|
||||
|
||||
SECTION("false") {
|
||||
pw.add_bool(1, false);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE_FALSE(msg.b());
|
||||
}
|
||||
@@ -23,7 +24,7 @@ TEST_CASE("write bool field and check with libprotobuf") {
|
||||
SECTION("true") {
|
||||
pw.add_bool(1, true);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.b());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ TEST_CASE("read bytes field: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_bytes(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_bytes(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestBytes::Test msg;
|
||||
|
||||
msg.set_s("");
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/bytes/bytes_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write bytes field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write bytes 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()};
|
||||
|
||||
TestBytes::Test msg;
|
||||
|
||||
SECTION("empty") {
|
||||
pw.add_string(1, "");
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s().empty());
|
||||
}
|
||||
@@ -21,7 +22,7 @@ TEST_CASE("write bytes field and check with libprotobuf") {
|
||||
SECTION("one") {
|
||||
pw.add_string(1, "x");
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s() == "x");
|
||||
}
|
||||
@@ -29,7 +30,7 @@ TEST_CASE("write bytes field and check with libprotobuf") {
|
||||
SECTION("string") {
|
||||
pw.add_string(1, "foobar");
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s() == "foobar");
|
||||
}
|
||||
@@ -42,7 +43,7 @@ TEST_CASE("write bytes field and check with libprotobuf") {
|
||||
|
||||
pw.add_string(1, data);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s().size() == 3);
|
||||
REQUIRE(msg.s()[1] == char(2));
|
||||
|
||||
+86
-30
@@ -1,6 +1,12 @@
|
||||
|
||||
#include <test.hpp>
|
||||
|
||||
#include <protozero/buffer_fixed.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <numeric>
|
||||
|
||||
namespace TestComplex {
|
||||
|
||||
enum class Test : protozero::pbf_tag_type {
|
||||
@@ -120,11 +126,7 @@ TEST_CASE("read complex data using pbf_reader: all") {
|
||||
}
|
||||
case 7: {
|
||||
const auto pi = item.get_packed_sint32();
|
||||
int32_t sum = 0;
|
||||
for (auto val : pi) {
|
||||
sum += val;
|
||||
}
|
||||
REQUIRE(sum == 5);
|
||||
REQUIRE(std::accumulate(pi.cbegin(), pi.cend(), 0) == 5);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
@@ -265,11 +267,7 @@ TEST_CASE("read complex data using pbf_message: all") {
|
||||
}
|
||||
case TestComplex::Test::packed_sint32_d: {
|
||||
const auto pi = item.get_packed_sint32();
|
||||
int32_t sum = 0;
|
||||
for (auto val : pi) {
|
||||
sum += val;
|
||||
}
|
||||
REQUIRE(sum == 5);
|
||||
REQUIRE(std::accumulate(pi.cbegin(), pi.cend(), 0) == 5);
|
||||
break;
|
||||
}
|
||||
case TestComplex::Test::optional_string_s: {
|
||||
@@ -416,7 +414,7 @@ TEST_CASE("write complex data using pbf_writer: all") {
|
||||
pw.add_uint32(4, 66);
|
||||
pw.add_uint32(4, 66);
|
||||
|
||||
const int32_t d[] = { -17, 22 };
|
||||
const std::array<int32_t, 2> d = {{ -17, 22 }};
|
||||
pw.add_packed_sint32(7, std::begin(d), std::end(d));
|
||||
|
||||
pw.add_int64(3, 555555555);
|
||||
@@ -453,15 +451,7 @@ TEST_CASE("write complex data using pbf_writer: all") {
|
||||
}
|
||||
case 7: {
|
||||
const auto pi = item.get_packed_sint32();
|
||||
int32_t sum = 0;
|
||||
for (auto val : pi) {
|
||||
sum += val;
|
||||
}
|
||||
REQUIRE(sum == 5);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
REQUIRE(item.get_string() == "optionalstring");
|
||||
REQUIRE(std::accumulate(pi.cbegin(), pi.cend(), 0) == 5);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -577,7 +567,7 @@ TEST_CASE("write complex data using pbf_builder: all") {
|
||||
pw.add_uint32(TestComplex::Test::repeated_uint32_u, 66);
|
||||
pw.add_uint32(TestComplex::Test::repeated_uint32_u, 66);
|
||||
|
||||
const int32_t d[] = { -17, 22 };
|
||||
const std::array<int32_t, 2> d = {{ -17, 22 }};
|
||||
pw.add_packed_sint32(TestComplex::Test::packed_sint32_d, std::begin(d), std::end(d));
|
||||
|
||||
pw.add_int64(TestComplex::Test::optional_int64_j, 555555555);
|
||||
@@ -614,15 +604,7 @@ TEST_CASE("write complex data using pbf_builder: all") {
|
||||
}
|
||||
case 7: {
|
||||
const auto pi = item.get_packed_sint32();
|
||||
int32_t sum = 0;
|
||||
for (auto val : pi) {
|
||||
sum += val;
|
||||
}
|
||||
REQUIRE(sum == 5);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
REQUIRE(item.get_string() == "optionalstring");
|
||||
REQUIRE(std::accumulate(pi.cbegin(), pi.cend(), 0) == 5);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -684,3 +666,77 @@ TEST_CASE("write complex with subwriter using pbf_builder") {
|
||||
check_message(buffer_test);
|
||||
}
|
||||
|
||||
TEST_CASE("write complex data using basic_pbf_writer<fixed_size_buffer_adaptor>: all") {
|
||||
std::string data;
|
||||
data.resize(10240);
|
||||
protozero::fixed_size_buffer_adaptor buffer{&*data.begin(), data.size()};
|
||||
protozero::basic_pbf_writer<protozero::fixed_size_buffer_adaptor> pw{buffer};
|
||||
pw.add_fixed32(1, 12345678);
|
||||
|
||||
std::string sdata;
|
||||
sdata.resize(10240);
|
||||
protozero::fixed_size_buffer_adaptor submessage{&*sdata.begin(), sdata.size()};
|
||||
protozero::basic_pbf_writer<protozero::fixed_size_buffer_adaptor> pws{submessage};
|
||||
pws.add_string(1, "foobar");
|
||||
pw.add_message(5, submessage.data(), submessage.size());
|
||||
|
||||
pw.add_uint32(4, 22);
|
||||
pw.add_uint32(4, 44);
|
||||
pw.add_int64(2, -9876543);
|
||||
pw.add_uint32(4, 44);
|
||||
pw.add_uint32(4, 66);
|
||||
pw.add_uint32(4, 66);
|
||||
|
||||
const std::array<int32_t, 2> d = {{ -17, 22 }};
|
||||
pw.add_packed_sint32(7, std::begin(d), std::end(d));
|
||||
|
||||
pw.add_int64(3, 555555555);
|
||||
|
||||
protozero::pbf_reader item{buffer.data(), buffer.size()};
|
||||
|
||||
int number_of_u = 0;
|
||||
while (item.next()) {
|
||||
switch (item.tag()) {
|
||||
case 1: {
|
||||
REQUIRE(item.get_fixed32() == 12345678L);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
REQUIRE(true);
|
||||
item.skip();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
REQUIRE(item.get_int64() == 555555555LL);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
item.skip();
|
||||
++number_of_u;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
protozero::pbf_reader subitem = item.get_message();
|
||||
REQUIRE(subitem.next());
|
||||
REQUIRE(subitem.get_string() == "foobar");
|
||||
REQUIRE_FALSE(subitem.next());
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
const auto pi = item.get_packed_sint32();
|
||||
REQUIRE(std::accumulate(pi.cbegin(), pi.cend(), 0) == 5);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
REQUIRE(item.get_string() == "optionalstring");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
REQUIRE(false); // should not be here
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUIRE(number_of_u == 5);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestComplex::Test msg;
|
||||
|
||||
msg.set_f(12345678);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST_CASE("read double field") {
|
||||
for (std::string::size_type i = 1; i < abuffer.size() - n; ++i) {
|
||||
protozero::pbf_reader item{abuffer.data() + n, i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_double(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_double(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestDouble::Test msg;
|
||||
|
||||
msg.set_x(0.0);
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/double/double_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write double field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write double 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()};
|
||||
|
||||
TestDouble::Test msg;
|
||||
|
||||
SECTION("zero") {
|
||||
pw.add_double(1, 0.0);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.x() == Approx(0.0));
|
||||
}
|
||||
@@ -21,7 +22,7 @@ TEST_CASE("write double field and check with libprotobuf") {
|
||||
SECTION("positive") {
|
||||
pw.add_double(1, 4.893);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.x() == Approx(4.893));
|
||||
}
|
||||
@@ -29,7 +30,7 @@ TEST_CASE("write double field and check with libprotobuf") {
|
||||
SECTION("negative") {
|
||||
pw.add_double(1, -9232.33);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.x() == Approx(-9232.33));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestEnum::Test msg;
|
||||
|
||||
msg.set_color(TestEnum::BLACK);
|
||||
|
||||
+10
-9
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/enum/enum_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write enum field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write enum 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()};
|
||||
|
||||
TestEnum::Test msg;
|
||||
|
||||
SECTION("zero") {
|
||||
pw.add_enum(1, 0L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.color() == TestEnum::Color::BLACK);
|
||||
}
|
||||
@@ -21,7 +22,7 @@ TEST_CASE("write enum field and check with libprotobuf") {
|
||||
SECTION("positive") {
|
||||
pw.add_enum(1, 3L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.color() == TestEnum::Color::BLUE);
|
||||
}
|
||||
@@ -29,7 +30,7 @@ TEST_CASE("write enum field and check with libprotobuf") {
|
||||
SECTION("negative") {
|
||||
pw.add_enum(1, -1L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.color() == TestEnum::Color::NEG);
|
||||
}
|
||||
@@ -37,7 +38,7 @@ TEST_CASE("write enum field and check with libprotobuf") {
|
||||
SECTION("max") {
|
||||
pw.add_enum(1, std::numeric_limits<int32_t>::max() - 1);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.color() == TestEnum::Color::MAX);
|
||||
}
|
||||
@@ -45,7 +46,7 @@ TEST_CASE("write enum field and check with libprotobuf") {
|
||||
SECTION("min") {
|
||||
pw.add_enum(1, std::numeric_limits<int32_t>::min() + 1);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.color() == TestEnum::Color::MIN);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestFixed32::Test msg;
|
||||
|
||||
msg.set_i(0);
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/fixed32/fixed32_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write fixed32 field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write 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()};
|
||||
|
||||
TestFixed32::Test msg;
|
||||
|
||||
SECTION("zero") {
|
||||
pw.add_fixed32(1, 0);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == 0);
|
||||
}
|
||||
@@ -21,7 +22,7 @@ TEST_CASE("write fixed32 field and check with libprotobuf") {
|
||||
SECTION("max") {
|
||||
pw.add_fixed32(1, std::numeric_limits<uint32_t>::max());
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == std::numeric_limits<uint32_t>::max());
|
||||
}
|
||||
@@ -29,7 +30,7 @@ TEST_CASE("write fixed32 field and check with libprotobuf") {
|
||||
SECTION("min") {
|
||||
pw.add_fixed32(1, std::numeric_limits<uint32_t>::min());
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == std::numeric_limits<uint32_t>::min());
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestFixed64::Test msg;
|
||||
|
||||
msg.set_i(0);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ TEST_CASE("read float field") {
|
||||
for (std::string::size_type i = 1; i < abuffer.size() - n; ++i) {
|
||||
protozero::pbf_reader item{abuffer.data() + n, i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_float(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_float(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,17 +57,17 @@ TEST_CASE("write float field") {
|
||||
protozero::pbf_writer pw{buffer};
|
||||
|
||||
SECTION("zero") {
|
||||
pw.add_float(1, 0.0f);
|
||||
pw.add_float(1, 0.0F);
|
||||
REQUIRE(buffer == load_data("float/data-zero"));
|
||||
}
|
||||
|
||||
SECTION("positive") {
|
||||
pw.add_float(1, 5.34f);
|
||||
pw.add_float(1, 5.34F);
|
||||
REQUIRE(buffer == load_data("float/data-pos"));
|
||||
}
|
||||
|
||||
SECTION("negative") {
|
||||
pw.add_float(1, -1.71f);
|
||||
pw.add_float(1, -1.71F);
|
||||
REQUIRE(buffer == load_data("float/data-neg"));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestFloat::Test msg;
|
||||
|
||||
msg.set_x(0.0);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestInt32::Test msg;
|
||||
|
||||
msg.set_i(0);
|
||||
|
||||
+10
-9
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/int32/int32_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write int32 field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write int32 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()};
|
||||
|
||||
TestInt32::Test msg;
|
||||
|
||||
SECTION("zero") {
|
||||
pw.add_int32(1, 0L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == 0L);
|
||||
}
|
||||
@@ -21,7 +22,7 @@ TEST_CASE("write int32 field and check with libprotobuf") {
|
||||
SECTION("positive") {
|
||||
pw.add_int32(1, 1L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == 1L);
|
||||
}
|
||||
@@ -29,7 +30,7 @@ TEST_CASE("write int32 field and check with libprotobuf") {
|
||||
SECTION("negative") {
|
||||
pw.add_int32(1, -1L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == -1L);
|
||||
}
|
||||
@@ -37,7 +38,7 @@ TEST_CASE("write int32 field and check with libprotobuf") {
|
||||
SECTION("max") {
|
||||
pw.add_int32(1, std::numeric_limits<int32_t>::max());
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == std::numeric_limits<int32_t>::max());
|
||||
}
|
||||
@@ -45,7 +46,7 @@ TEST_CASE("write int32 field and check with libprotobuf") {
|
||||
SECTION("min") {
|
||||
pw.add_int32(1, std::numeric_limits<int32_t>::min());
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == std::numeric_limits<int32_t>::min());
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestInt64::Test msg;
|
||||
|
||||
msg.set_i(0);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
@@ -6,10 +6,16 @@ TEST_CASE("read message field: string") {
|
||||
|
||||
protozero::pbf_reader item{buffer};
|
||||
|
||||
REQUIRE(item.data().data() == buffer.data());
|
||||
REQUIRE(item.data().size() == buffer.size());
|
||||
|
||||
REQUIRE(item.next());
|
||||
protozero::pbf_reader subitem{item.get_message()};
|
||||
REQUIRE_FALSE(item.next());
|
||||
|
||||
REQUIRE(item.data().data() == buffer.data() + buffer.size());
|
||||
REQUIRE(item.data().empty());
|
||||
|
||||
REQUIRE(subitem.next());
|
||||
REQUIRE(subitem.get_string() == "foobar");
|
||||
REQUIRE_FALSE(subitem.next());
|
||||
@@ -21,7 +27,7 @@ TEST_CASE("read message field: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_string(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_string(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestMessage::Test msg;
|
||||
|
||||
TestMessage::Sub* submsg = msg.mutable_submessage();
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/message/message_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write message field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write message field and check with libprotobuf", "",
|
||||
buffer_test_string, buffer_test_vector, buffer_test_array, buffer_test_external) {
|
||||
|
||||
std::string buffer_test;
|
||||
protozero::pbf_writer pbf_test{buffer_test};
|
||||
TestType buffer;
|
||||
typename TestType::writer_type pw{buffer.buffer()};
|
||||
|
||||
SECTION("string") {
|
||||
std::string buffer_submessage;
|
||||
protozero::pbf_writer pbf_submessage{buffer_submessage};
|
||||
pbf_submessage.add_string(1, "foobar");
|
||||
|
||||
pbf_test.add_message(1, buffer_submessage);
|
||||
pw.add_message(1, buffer_submessage);
|
||||
}
|
||||
|
||||
SECTION("string with subwriter") {
|
||||
protozero::pbf_writer pbf_submessage{pbf_test, 1};
|
||||
typename TestType::writer_type pbf_submessage{pw, 1};
|
||||
pbf_submessage.add_string(1, "foobar");
|
||||
}
|
||||
|
||||
TestMessage::Test msg;
|
||||
msg.ParseFromString(buffer_test);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
REQUIRE(msg.submessage().s() == "foobar");
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestNested::Test msg;
|
||||
msg.set_i(77);
|
||||
|
||||
|
||||
+10
-9
@@ -1,12 +1,13 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/nested/nested_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write nested message fields and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write nested message fields and check with libprotobuf", "",
|
||||
buffer_test_string, buffer_test_vector, buffer_test_array, buffer_test_external) {
|
||||
|
||||
std::string buffer_test;
|
||||
protozero::pbf_writer pbf_test{buffer_test};
|
||||
TestType buffer;
|
||||
typename TestType::writer_type pw{buffer.buffer()};
|
||||
|
||||
SECTION("string") {
|
||||
std::string buffer_subsub;
|
||||
@@ -19,23 +20,23 @@ TEST_CASE("write nested message fields and check with libprotobuf") {
|
||||
pbf_sub.add_string(1, buffer_subsub);
|
||||
pbf_sub.add_int32(2, 88);
|
||||
|
||||
pbf_test.add_message(1, buffer_sub);
|
||||
pw.add_message(1, buffer_sub);
|
||||
}
|
||||
|
||||
SECTION("with subwriter") {
|
||||
protozero::pbf_writer pbf_sub{pbf_test, 1};
|
||||
typename TestType::writer_type pbf_sub{pw, 1};
|
||||
{
|
||||
protozero::pbf_writer pbf_subsub(pbf_sub, 1);
|
||||
typename TestType::writer_type pbf_subsub(pbf_sub, 1);
|
||||
pbf_subsub.add_string(1, "foobar");
|
||||
pbf_subsub.add_int32(2, 99);
|
||||
}
|
||||
pbf_sub.add_int32(2, 88);
|
||||
}
|
||||
|
||||
pbf_test.add_int32(2, 77);
|
||||
pw.add_int32(2, 77);
|
||||
|
||||
TestNested::Test msg;
|
||||
msg.ParseFromString(buffer_test);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i() == 77);
|
||||
REQUIRE(msg.sub().i() == 88);
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST_CASE("read repeated fields: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_int32(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_int32(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeated::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/repeated/repeated_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write repeated fields and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write repeated fields 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()};
|
||||
|
||||
TestRepeated::Test msg;
|
||||
|
||||
SECTION("one") {
|
||||
pw.add_int32(1, 0L);
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i().size() == 1);
|
||||
REQUIRE(msg.i(0) == 0L);
|
||||
@@ -26,7 +27,7 @@ TEST_CASE("write repeated fields and check with libprotobuf") {
|
||||
pw.add_int32(1, std::numeric_limits<int32_t>::max());
|
||||
pw.add_int32(1, std::numeric_limits<int32_t>::min());
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.i().size() == 5);
|
||||
REQUIRE(msg.i(0) == 0L);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#include <test.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
TEST_CASE("read repeated packed bool field: empty") {
|
||||
const std::string buffer = load_data("repeated_packed_bool/data-empty");
|
||||
|
||||
@@ -51,7 +53,7 @@ TEST_CASE("read repeated packed bool field: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_packed_bool(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_packed_bool(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,21 +62,21 @@ TEST_CASE("write repeated packed bool field") {
|
||||
protozero::pbf_writer pw{buffer};
|
||||
|
||||
SECTION("empty") {
|
||||
const bool data[] = { true };
|
||||
const std::array<bool, 1> data = {{ true }};
|
||||
pw.add_packed_bool(1, std::begin(data), std::begin(data) /* !!!! */);
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_bool/data-empty"));
|
||||
}
|
||||
|
||||
SECTION("one") {
|
||||
const bool data[] = { true };
|
||||
const std::array<bool, 1> data = {{ true }};
|
||||
pw.add_packed_bool(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_bool/data-one"));
|
||||
}
|
||||
|
||||
SECTION("many") {
|
||||
const bool data[] = { true, true, false, true };
|
||||
const std::array<bool, 4> data = {{ true, true, false, true }};
|
||||
pw.add_packed_bool(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_bool/data-many"));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedBool::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#include <test.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
TEST_CASE("read repeated packed double field") {
|
||||
// Run these tests twice, the second time we basically move the data
|
||||
// one byte down in the buffer. It doesn't matter how the data or buffer
|
||||
@@ -82,7 +84,7 @@ TEST_CASE("read repeated packed double field") {
|
||||
for (std::string::size_type i = 1; i < abuffer.size() - n; ++i) {
|
||||
protozero::pbf_reader item{abuffer.data() + n, i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_packed_double(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_packed_double(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,21 +95,23 @@ TEST_CASE("write repeated packed double field") {
|
||||
protozero::pbf_writer pw{buffer};
|
||||
|
||||
SECTION("empty") {
|
||||
const double data[] = { 17.34 };
|
||||
const std::array<double, 1> data = {{ 17.34 }};
|
||||
pw.add_packed_double(1, std::begin(data), std::begin(data) /* !!!! */);
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_double/data-empty"));
|
||||
}
|
||||
|
||||
SECTION("one") {
|
||||
const double data[] = { 17.34 };
|
||||
const std::array<double, 1> data = {{ 17.34 }};
|
||||
pw.add_packed_double(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_double/data-one"));
|
||||
}
|
||||
|
||||
SECTION("many") {
|
||||
const double data[] = { 17.34, 0.0, 1.0, std::numeric_limits<double>::min(), std::numeric_limits<double>::max() };
|
||||
const std::array<double, 5> data = {{ 17.34, 0.0, 1.0,
|
||||
std::numeric_limits<double>::min(),
|
||||
std::numeric_limits<double>::max() }};
|
||||
pw.add_packed_double(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_double/data-many"));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedDouble::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#include <test.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
TEST_CASE("read repeated packed enum field: empty") {
|
||||
const std::string buffer = load_data("repeated_packed_enum/data-empty");
|
||||
|
||||
@@ -46,7 +48,7 @@ TEST_CASE("read repeated packed enum field: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_packed_enum(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_packed_enum(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,21 +57,21 @@ TEST_CASE("write repeated packed enum field") {
|
||||
protozero::pbf_writer pw{buffer};
|
||||
|
||||
SECTION("empty") {
|
||||
const int32_t data[] = { 0 /* BLACK */ };
|
||||
const std::array<int32_t, 1> data = {{ 0 /* BLACK */ }};
|
||||
pw.add_packed_enum(1, std::begin(data), std::begin(data) /* !!!! */);
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_enum/data-empty"));
|
||||
}
|
||||
|
||||
SECTION("one") {
|
||||
const int32_t data[] = { 0 /* BLACK */ };
|
||||
const std::array<int32_t, 1> data = {{ 0 /* BLACK */ }};
|
||||
pw.add_packed_enum(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_enum/data-one"));
|
||||
}
|
||||
|
||||
SECTION("many") {
|
||||
const int32_t data[] = { 0 /* BLACK */, 3 /* BLUE */, 2 /* GREEN */ };
|
||||
const std::array<int32_t, 3> data = {{ 0 /* BLACK */, 3 /* BLUE */, 2 /* GREEN */ }};
|
||||
pw.add_packed_enum(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_enum/data-many"));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedEnum::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
Vendored
+1
@@ -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");
|
||||
|
||||
+21
-16
@@ -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);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedFixed64::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#include <test.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
TEST_CASE("read repeated packed float field") {
|
||||
// Run these tests twice, the second time we basically move the data
|
||||
// one byte down in the buffer. It doesn't matter how the data or buffer
|
||||
@@ -28,7 +30,7 @@ TEST_CASE("read repeated packed float field") {
|
||||
auto it_range = item.get_packed_float();
|
||||
REQUIRE_FALSE(item.next());
|
||||
|
||||
REQUIRE(*it_range.begin() == Approx(17.34f));
|
||||
REQUIRE(*it_range.begin() == Approx(17.34F));
|
||||
REQUIRE(std::next(it_range.begin()) == it_range.end());
|
||||
}
|
||||
|
||||
@@ -41,9 +43,9 @@ TEST_CASE("read repeated packed float field") {
|
||||
REQUIRE_FALSE(item.next());
|
||||
|
||||
auto it = it_range.begin();
|
||||
REQUIRE(*it++ == Approx(17.34f));
|
||||
REQUIRE(*it++ == Approx( 0.0f));
|
||||
REQUIRE(*it++ == Approx( 1.0f));
|
||||
REQUIRE(*it++ == Approx(17.34F));
|
||||
REQUIRE(*it++ == Approx( 0.0F));
|
||||
REQUIRE(*it++ == Approx( 1.0F));
|
||||
REQUIRE(*it++ == std::numeric_limits<float>::min());
|
||||
REQUIRE(*it++ == std::numeric_limits<float>::max());
|
||||
REQUIRE(it == it_range.end());
|
||||
@@ -55,7 +57,7 @@ TEST_CASE("read repeated packed float field") {
|
||||
for (std::string::size_type i = 1; i < abuffer.size() - n; ++i) {
|
||||
protozero::pbf_reader item{abuffer.data() + n, i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_packed_float(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_packed_float(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,21 +68,21 @@ TEST_CASE("write repeated packed float field") {
|
||||
protozero::pbf_writer pw{buffer};
|
||||
|
||||
SECTION("empty") {
|
||||
float data[] = { 17.34f };
|
||||
const std::array<float, 1> data = {{ 17.34F }};
|
||||
pw.add_packed_float(1, std::begin(data), std::begin(data) /* !!!! */);
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_float/data-empty"));
|
||||
}
|
||||
|
||||
SECTION("one") {
|
||||
float data[] = { 17.34f };
|
||||
const std::array<float, 1> data = {{ 17.34F }};
|
||||
pw.add_packed_float(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_float/data-one"));
|
||||
}
|
||||
|
||||
SECTION("many") {
|
||||
float data[] = { 17.34f, 0.0f, 1.0f, std::numeric_limits<float>::min(), std::numeric_limits<float>::max() };
|
||||
const std::array<float, 5> data = {{ 17.34F, 0.0F, 1.0F, std::numeric_limits<float>::min(), std::numeric_limits<float>::max() }};
|
||||
pw.add_packed_float(1, std::begin(data), std::end(data));
|
||||
|
||||
REQUIRE(buffer == load_data("repeated_packed_float/data-many"));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedFloat::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedInt32::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedInt64::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ TEST_CASE("length value must be dividable by sizeof(T)") {
|
||||
protozero::pbf_reader item{data};
|
||||
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_packed_sfixed32(), const protozero::invalid_length_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_packed_sfixed32(), protozero::invalid_length_exception);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedSFixed32::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedSFixed64::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedSInt32::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedSInt64::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedUInt32::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestRepeatedPackedUInt64::Test msg;
|
||||
|
||||
write_to_file(msg, "data-empty.pbf");
|
||||
|
||||
@@ -131,7 +131,7 @@ TEST_CASE("rollback when using packed_field functions") {
|
||||
protozero::packed_field_sint64 field{pw, 1};
|
||||
field.add_element(1L);
|
||||
field.rollback();
|
||||
REQUIRE_THROWS_AS(field.add_element(1L), const assert_error&);
|
||||
REQUIRE_THROWS_AS(field.add_element(1L), assert_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ TEST_CASE("rollback when using submessages") {
|
||||
TEST_CASE("rollback on parent message is never allowed") {
|
||||
std::string buffer;
|
||||
protozero::pbf_writer pw{buffer};
|
||||
REQUIRE_THROWS_AS(pw.rollback(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(pw.rollback(), assert_error);
|
||||
}
|
||||
|
||||
TEST_CASE("rollback on parent message is not allowed even if there is a submessage") {
|
||||
@@ -183,7 +183,7 @@ TEST_CASE("rollback on parent message is not allowed even if there is a submessa
|
||||
{
|
||||
protozero::pbf_writer pws{pw, 1};
|
||||
pws.add_string(1, "foobar");
|
||||
REQUIRE_THROWS_AS(pw.rollback(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(pw.rollback(), assert_error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ TEST_CASE("rollback on message is not allowed if there is a nested submessage")
|
||||
protozero::pbf_writer pws{pw, 1};
|
||||
pws.add_string(1, "foobar");
|
||||
protozero::pbf_writer pws2{pws, 1};
|
||||
REQUIRE_THROWS_AS(pws.rollback(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(pws.rollback(), assert_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestSFixed32::Test msg;
|
||||
|
||||
msg.set_i(0);
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestSFixed64::Test msg;
|
||||
|
||||
msg.set_i(0);
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestSInt32::Test msg;
|
||||
|
||||
msg.set_i(0L);
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestSInt64::Test msg;
|
||||
|
||||
msg.set_i(0LL);
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ TEST_CASE("exceptional cases") {
|
||||
|
||||
protozero::pbf_reader item{buffer};
|
||||
|
||||
REQUIRE_THROWS_AS(item.next(), const protozero::unknown_pbf_wire_type_exception&);
|
||||
REQUIRE_THROWS_AS(item.next(), protozero::unknown_pbf_wire_type_exception);
|
||||
}
|
||||
|
||||
SECTION("check that skip() throws on short buffer") {
|
||||
@@ -124,7 +124,7 @@ TEST_CASE("exceptional cases") {
|
||||
protozero::pbf_reader item{buffer};
|
||||
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.skip(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.skip(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST_CASE("read string field using get_string: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_string(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_string(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ TEST_CASE("read string field using get_view: end of buffer") {
|
||||
for (std::string::size_type i = 1; i < buffer.size(); ++i) {
|
||||
protozero::pbf_reader item{buffer.data(), i};
|
||||
REQUIRE(item.next());
|
||||
REQUIRE_THROWS_AS(item.get_view(), const protozero::end_of_buffer_exception&);
|
||||
REQUIRE_THROWS_AS(item.get_view(), protozero::end_of_buffer_exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestString::Test msg;
|
||||
|
||||
msg.set_s("");
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
|
||||
#include <test.hpp>
|
||||
#include <buffer.hpp>
|
||||
|
||||
#include "t/string/string_testcase.pb.h"
|
||||
|
||||
TEST_CASE("write string field and check with libprotobuf") {
|
||||
TEMPLATE_TEST_CASE("write string 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()};
|
||||
|
||||
TestString::Test msg;
|
||||
|
||||
SECTION("empty") {
|
||||
pw.add_string(1, "");
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s().empty());
|
||||
}
|
||||
@@ -21,7 +22,7 @@ TEST_CASE("write string field and check with libprotobuf") {
|
||||
SECTION("one") {
|
||||
pw.add_string(1, "x");
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s() == "x");
|
||||
}
|
||||
@@ -29,7 +30,7 @@ TEST_CASE("write string field and check with libprotobuf") {
|
||||
SECTION("string") {
|
||||
pw.add_string(1, "foobar");
|
||||
|
||||
msg.ParseFromString(buffer);
|
||||
msg.ParseFromArray(buffer.data(), buffer.size());
|
||||
|
||||
REQUIRE(msg.s() == "foobar");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -17,9 +19,7 @@ inline std::vector<uint32_t> read_data(const std::string& data) {
|
||||
switch (message.tag_and_type()) {
|
||||
case tag_and_type(ExampleMsg::repeated_uint32_x, protozero::pbf_wire_type::length_delimited): {
|
||||
const auto xit = message.get_packed_uint32();
|
||||
for (const auto value : xit) {
|
||||
values.push_back(value);
|
||||
}
|
||||
std::copy(xit.cbegin(), xit.cend(), std::back_inserter(values));
|
||||
}
|
||||
break;
|
||||
case tag_and_type(ExampleMsg::repeated_uint32_x, protozero::pbf_wire_type::varint): {
|
||||
@@ -28,7 +28,7 @@ inline std::vector<uint32_t> read_data(const std::string& data) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
message.skip();
|
||||
REQUIRE(false); // should never be here
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ inline std::vector<uint32_t> read_data_packed(const std::string& data) {
|
||||
protozero::pbf_message<ExampleMsg> message{data};
|
||||
while (message.next(ExampleMsg::repeated_uint32_x, protozero::pbf_wire_type::length_delimited)) {
|
||||
const auto xit = message.get_packed_uint32();
|
||||
for (const auto value : xit) {
|
||||
values.push_back(value);
|
||||
}
|
||||
std::copy(xit.cbegin(), xit.cend(), std::back_inserter(values));
|
||||
}
|
||||
|
||||
return values;
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
|
||||
std::string out;
|
||||
|
||||
|
||||
+5
-5
@@ -11,19 +11,19 @@ inline void check_tag(const std::string& buffer, protozero::pbf_tag_type tag) {
|
||||
}
|
||||
|
||||
TEST_CASE("read tag: 1") {
|
||||
check_tag(load_data("tags/data-tag-1"), 1ul);
|
||||
check_tag(load_data("tags/data-tag-1"), 1UL);
|
||||
}
|
||||
|
||||
TEST_CASE("read tag: 200") {
|
||||
check_tag(load_data("tags/data-tag-200"), 200ul);
|
||||
check_tag(load_data("tags/data-tag-200"), 200UL);
|
||||
}
|
||||
|
||||
TEST_CASE("read tag: 200000") {
|
||||
check_tag(load_data("tags/data-tag-200000"), 200000ul);
|
||||
check_tag(load_data("tags/data-tag-200000"), 200000UL);
|
||||
}
|
||||
|
||||
TEST_CASE("read tag: max") {
|
||||
check_tag(load_data("tags/data-tag-max"), (1ul << 29u) - 1u);
|
||||
check_tag(load_data("tags/data-tag-max"), (1UL << 29U) - 1U);
|
||||
}
|
||||
|
||||
TEST_CASE("write tags") {
|
||||
@@ -46,7 +46,7 @@ TEST_CASE("write tags") {
|
||||
}
|
||||
|
||||
SECTION("tag max") {
|
||||
pw.add_int32(static_cast<int32_t>((1ul << 29u) - 1u), 333L);
|
||||
pw.add_int32(static_cast<int32_t>((1UL << 29U) - 1U), 333L);
|
||||
REQUIRE(buffer == load_data("tags/data-tag-max"));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
|
||||
{
|
||||
TestTags::Test1 msg;
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestUInt32::Test msg;
|
||||
|
||||
msg.set_i(0ul);
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
#include <testcase.hpp>
|
||||
|
||||
#include "testcase.pb.h"
|
||||
|
||||
int main(int c, char *argv[]) {
|
||||
int main() {
|
||||
TestUInt64::Test msg;
|
||||
|
||||
msg.set_i(0ul);
|
||||
|
||||
@@ -11,6 +11,7 @@ static std::string get_name(protozero::pbf_reader layer) { // copy!
|
||||
while (layer.next(1)) { // required string name
|
||||
return layer.get_string();
|
||||
}
|
||||
REQUIRE(false); // should never be here
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -42,6 +43,7 @@ TEST_CASE("reading vector tiles") {
|
||||
}
|
||||
} else {
|
||||
item.skip();
|
||||
REQUIRE(false); // should never be here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ TEST_CASE("check assert on non-varint access to varint") {
|
||||
REQUIRE(item.next());
|
||||
|
||||
REQUIRE(item.get_int32() == 0);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_string(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), assert_error);
|
||||
REQUIRE_THROWS_AS(item.get_string(), assert_error);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), assert_error);
|
||||
}
|
||||
|
||||
// protobuf wire type 1
|
||||
@@ -21,10 +21,10 @@ TEST_CASE("check assert on non-fixed access to fixed64") {
|
||||
protozero::pbf_reader item{buffer};
|
||||
REQUIRE(item.next());
|
||||
|
||||
REQUIRE_THROWS_AS(item.get_int32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_int32(), assert_error);
|
||||
REQUIRE(item.get_fixed64() == 0);
|
||||
REQUIRE_THROWS_AS(item.get_string(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_string(), assert_error);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), assert_error);
|
||||
}
|
||||
|
||||
// protobuf wire type 2
|
||||
@@ -34,10 +34,10 @@ TEST_CASE("check assert on non-string access to string") {
|
||||
protozero::pbf_reader item{buffer};
|
||||
REQUIRE(item.next());
|
||||
|
||||
REQUIRE_THROWS_AS(item.get_int32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_int32(), assert_error);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), assert_error);
|
||||
REQUIRE(item.get_string() == "foobar");
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed32(), assert_error);
|
||||
}
|
||||
|
||||
// protobuf wire type 5
|
||||
@@ -47,9 +47,9 @@ TEST_CASE("check assert on non-fixed access to fixed32") {
|
||||
protozero::pbf_reader item{buffer};
|
||||
REQUIRE(item.next());
|
||||
|
||||
REQUIRE_THROWS_AS(item.get_int32(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_string(), const assert_error&);
|
||||
REQUIRE_THROWS_AS(item.get_int32(), assert_error);
|
||||
REQUIRE_THROWS_AS(item.get_fixed64(), assert_error);
|
||||
REQUIRE_THROWS_AS(item.get_string(), assert_error);
|
||||
REQUIRE(item.get_fixed32() == 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user