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,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");