git-subtree-dir: third_party/protozero git-subtree-split: d5d8debf1b17c6bb652395957b76cde7787e5377
39 lines
748 B
C++
39 lines
748 B
C++
|
|
#include <test.hpp>
|
|
|
|
#include "t/fixed32/fixed32_testcase.pb.h"
|
|
|
|
TEST_CASE("write fixed32 field and check with libprotobuf") {
|
|
|
|
std::string buffer;
|
|
protozero::pbf_writer pw{buffer};
|
|
|
|
TestFixed32::Test msg;
|
|
|
|
SECTION("zero") {
|
|
pw.add_fixed32(1, 0);
|
|
|
|
msg.ParseFromString(buffer);
|
|
|
|
REQUIRE(msg.i() == 0);
|
|
}
|
|
|
|
SECTION("max") {
|
|
pw.add_fixed32(1, std::numeric_limits<uint32_t>::max());
|
|
|
|
msg.ParseFromString(buffer);
|
|
|
|
REQUIRE(msg.i() == std::numeric_limits<uint32_t>::max());
|
|
}
|
|
|
|
SECTION("min") {
|
|
pw.add_fixed32(1, std::numeric_limits<uint32_t>::min());
|
|
|
|
msg.ParseFromString(buffer);
|
|
|
|
REQUIRE(msg.i() == std::numeric_limits<uint32_t>::min());
|
|
}
|
|
|
|
}
|
|
|