osrm-backend/test/t/fixed32/writer_test_cases.cpp
Michael Krasnyk 68019a1fb2 Squashed 'third_party/protozero/' content from commit d5d8debf1
git-subtree-dir: third_party/protozero
git-subtree-split: d5d8debf1b17c6bb652395957b76cde7787e5377
2018-04-19 22:03:49 +03:00

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());
}
}