File: SOPClassCommonExtendedNegotiation.cpp

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (87 lines) | stat: -rw-r--r-- 2,585 bytes parent folder | download | duplicates (6)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#define BOOST_TEST_MODULE SOPClassCommonExtendedNegotiation
#include <boost/test/unit_test.hpp>

#include <sstream>
#include <string>

#include "odil/Exception.h"
#include "odil/pdu/SOPClassCommonExtendedNegotiation.h"

BOOST_AUTO_TEST_CASE(Constructor)
{
    odil::pdu::SOPClassCommonExtendedNegotiation const item(
        "sop_class", "service_class", {"foo", "bar"});
    BOOST_REQUIRE_EQUAL(item.get_sop_class_uid(), "sop_class");
    BOOST_REQUIRE_EQUAL(item.get_service_class_uid(), "service_class");
    BOOST_REQUIRE(
        item.get_related_general_sop_class_uids() ==
            std::vector<std::string>({"foo", "bar"}));
}

BOOST_AUTO_TEST_CASE(FromStream)
{
    std::string const data(
        "\x57\x00\x00\x26"
        "\x00\x09" "sop_class"
        "\x00\x0d" "service_class"
        "\x00\x0a"
            "\x00\x03" "foo"
            "\x00\x03" "bar",
        42
    );
    std::istringstream stream(data);

    odil::pdu::SOPClassCommonExtendedNegotiation const item(stream);

    BOOST_REQUIRE_EQUAL(item.get_sop_class_uid(), "sop_class");
    BOOST_REQUIRE_EQUAL(item.get_service_class_uid(), "service_class");
    BOOST_REQUIRE(
        item.get_related_general_sop_class_uids() ==
            std::vector<std::string>({"foo", "bar"}));
}

BOOST_AUTO_TEST_CASE(SOPClassUID)
{
    odil::pdu::SOPClassCommonExtendedNegotiation item(
        "sop_class", "service_class", {"foo", "bar"});
    item.set_sop_class_uid("bar");
    BOOST_REQUIRE_EQUAL(item.get_sop_class_uid(), "bar");
}

BOOST_AUTO_TEST_CASE(ServiceClassUID)
{
    odil::pdu::SOPClassCommonExtendedNegotiation item(
        "sop_class", "service_class", {"foo", "bar"});
    item.set_service_class_uid("bar");
    BOOST_REQUIRE_EQUAL(item.get_service_class_uid(), "bar");
}

BOOST_AUTO_TEST_CASE(RelatedClasses)
{
    odil::pdu::SOPClassCommonExtendedNegotiation item(
        "sop_class", "service_class", {"foo", "bar"});
    item.set_related_general_sop_class_uids({"plip", "plop", "plup"});
    BOOST_REQUIRE(
        item.get_related_general_sop_class_uids() ==
            std::vector<std::string>({"plip", "plop", "plup"}));
}

BOOST_AUTO_TEST_CASE(Write)
{
    odil::pdu::SOPClassCommonExtendedNegotiation const item(
        "sop_class", "service_class", {"foo", "bar"});
    std::ostringstream data;
    data << item;

    std::string const expected(
        "\x57\x00\x00\x26"
        "\x00\x09" "sop_class"
        "\x00\x0d" "service_class"
        "\x00\x0a"
            "\x00\x03" "foo"
            "\x00\x03" "bar",
        42
    );

    BOOST_REQUIRE_EQUAL(data.str(), expected);
}