Squashed 'third_party/protozero/' content from commit d5d8debf1

git-subtree-dir: third_party/protozero
git-subtree-split: d5d8debf1b17c6bb652395957b76cde7787e5377
This commit is contained in:
Michael Krasnyk
2018-04-19 22:03:49 +03:00
commit 68019a1fb2
321 changed files with 26809 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,30 @@
#include <test.hpp>
#define PBF_TYPE sfixed32
#define PBF_TYPE_IS_SIGNED 1
using cpp_type = int32_t;
#include <packed_access.hpp>
TEST_CASE("length value must be dividable by sizeof(T)") {
std::string data{load_data("repeated_packed_sfixed32/data-many")};
SECTION("1") {
data[1] = 1;
}
SECTION("2") {
data[1] = 2;
}
SECTION("3") {
data[1] = 3;
}
protozero::pbf_reader item{data};
REQUIRE(item.next());
REQUIRE_THROWS_AS(item.get_packed_sfixed32(), const protozero::invalid_length_exception&);
}
@@ -0,0 +1,22 @@
#include <testcase.hpp>
#include "testcase.pb.h"
int main(int c, char *argv[]) {
TestRepeatedPackedSFixed32::Test msg;
write_to_file(msg, "data-empty.pbf");
msg.add_i(17);
write_to_file(msg, "data-one.pbf");
msg.add_i(200);
msg.add_i(0);
msg.add_i(1);
msg.add_i(std::numeric_limits<int32_t>::max());
msg.add_i(-200);
msg.add_i(-1);
msg.add_i(std::numeric_limits<int32_t>::min());
write_to_file(msg, "data-many.pbf");
}
@@ -0,0 +1,11 @@
option optimize_for = LITE_RUNTIME;
package TestRepeatedPackedSFixed32;
message Test {
repeated sfixed32 i = 1 [packed=true];
}