File: Message.cpp

package info (click to toggle)
odil 0.12.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,304 kB
  • sloc: cpp: 55,034; python: 3,971; javascript: 460; xml: 182; makefile: 97
file content (63 lines) | stat: -rw-r--r-- 1,771 bytes parent folder | download | duplicates (5)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#define BOOST_TEST_MODULE Message
#include <boost/test/unit_test.hpp>

#include "odil/DataSet.h"
#include "odil/message/Message.h"

BOOST_AUTO_TEST_CASE(DefaultConstructor)
{
    odil::message::Message const message;

    // Command Set might not be empty (Command Group Length, Data Set Type)
    BOOST_CHECK(!message.has_data_set());
}

BOOST_AUTO_TEST_CASE(Constructor)
{
    auto command_set = std::make_shared<odil::DataSet>();
    command_set->add(
        "CommandField", {odil::message::Message::Command::C_ECHO_RQ});

    auto data_set = std::make_shared<odil::DataSet>();

    odil::message::Message const message(command_set, data_set);

    BOOST_CHECK_EQUAL(
        message.get_command_set()->as_int("CommandField", 0),
        odil::message::Message::Command::C_ECHO_RQ);

    BOOST_CHECK(message.has_data_set());
    BOOST_CHECK(message.get_data_set()->empty());

    BOOST_CHECK_EQUAL(
        message.get_command_field(),
        odil::message::Message::Command::C_ECHO_RQ);
}

BOOST_AUTO_TEST_CASE(CommandField)
{
    odil::message::Message message;
    message.set_command_field(odil::message::Message::Command::C_FIND_RSP);

    BOOST_CHECK(
        message.get_command_set()->as_int("CommandField") ==
            odil::Value::Integers(
                {odil::message::Message::Command::C_FIND_RSP}));
    BOOST_CHECK_EQUAL(
        message.get_command_field(),
        odil::message::Message::Command::C_FIND_RSP);
}

BOOST_AUTO_TEST_CASE(DeleteDataSet)
{
    auto command_set = std::make_shared<odil::DataSet>();
    auto data_set = std::make_shared<odil::DataSet>();

    odil::message::Message message(command_set, data_set);

    BOOST_CHECK(message.has_data_set());

    message.delete_data_set();

    BOOST_CHECK(!message.has_data_set());
}