File: writer_test_cases.cpp

package info (click to toggle)
protozero 1.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,548 kB
  • sloc: cpp: 20,364; sh: 18; makefile: 14
file content (39 lines) | stat: -rw-r--r-- 926 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

#include <buffer.hpp>

#include "t/fixed32/fixed32_testcase.pb.h"

TEMPLATE_TEST_CASE("write fixed32 field and check with libprotobuf", "",
    buffer_test_string, buffer_test_vector, buffer_test_array, buffer_test_external) {

    TestType buffer;
    typename TestType::writer_type pw{buffer.buffer()};

    TestFixed32::Test msg;

    SECTION("zero") {
        pw.add_fixed32(1, 0);

        msg.ParseFromArray(buffer.data(), buffer.size());

        REQUIRE(msg.i() == 0);
    }

    SECTION("max") {
        pw.add_fixed32(1, std::numeric_limits<uint32_t>::max());

        msg.ParseFromArray(buffer.data(), buffer.size());

        REQUIRE(msg.i() == std::numeric_limits<uint32_t>::max());
    }

    SECTION("min") {
        pw.add_fixed32(1, std::numeric_limits<uint32_t>::min());

        msg.ParseFromArray(buffer.data(), buffer.size());

        REQUIRE(msg.i() == std::numeric_limits<uint32_t>::min());
    }

}