File: writer_test_cases.cpp

package info (click to toggle)
protozero 1.5.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,048 kB
  • ctags: 1,005
  • sloc: cpp: 13,576; makefile: 123; sh: 14
file content (38 lines) | stat: -rw-r--r-- 623 bytes parent folder | download | duplicates (2)
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

#include <test.hpp>

#include "test/t/string/testcase.pb.h"

TEST_CASE("write string field and check with libprotobuf") {

    std::string buffer;
    protozero::pbf_writer pw(buffer);

    TestString::Test msg;

    SECTION("empty") {
        pw.add_string(1, "");

        msg.ParseFromString(buffer);

        REQUIRE(msg.s() == "");
    }

    SECTION("one") {
        pw.add_string(1, "x");

        msg.ParseFromString(buffer);

        REQUIRE(msg.s() == "x");
    }

    SECTION("string") {
        pw.add_string(1, "foobar");

        msg.ParseFromString(buffer);

        REQUIRE(msg.s() == "foobar");
    }

}