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
|
#define BOOST_TEST_MODULE pdu::AssociateRJ
#include <boost/test/unit_test.hpp>
#include <sstream>
#include "odil/pdu/AAssociateRJ.h"
#include "odil/Exception.h"
std::string const data = {
0x03, 0x00,
0x00, 0x00, 0x00, 0x04,
0x00, 0x01,
0x02, 0x03
};
BOOST_AUTO_TEST_CASE(ConstructorFields)
{
odil::pdu::AAssociateRJ const pdu(1, 2, 3);
BOOST_REQUIRE_EQUAL(pdu.get_result(), 1);
BOOST_REQUIRE_EQUAL(pdu.get_source(), 2);
BOOST_REQUIRE_EQUAL(pdu.get_reason(), 3);
}
BOOST_AUTO_TEST_CASE(ConstructorStream)
{
std::istringstream stream(data);
odil::pdu::AAssociateRJ const pdu(stream);
BOOST_REQUIRE_EQUAL(pdu.get_result(), 1);
BOOST_REQUIRE_EQUAL(pdu.get_source(), 2);
BOOST_REQUIRE_EQUAL(pdu.get_reason(), 3);
}
BOOST_AUTO_TEST_CASE(Write)
{
odil::pdu::AAssociateRJ const pdu(1, 2, 3);
std::ostringstream stream;
stream << pdu;
BOOST_REQUIRE(stream.str() == data);
}
BOOST_AUTO_TEST_CASE(WrongResult)
{
odil::pdu::AAssociateRJ pdu(1, 2, 3);
BOOST_REQUIRE_THROW(pdu.set_result(4), odil::Exception);
}
BOOST_AUTO_TEST_CASE(WrongSource)
{
odil::pdu::AAssociateRJ pdu(1, 2, 3);
BOOST_REQUIRE_THROW(pdu.set_source(4), odil::Exception);
}
BOOST_AUTO_TEST_CASE(WrongReason)
{
odil::pdu::AAssociateRJ pdu(1, 2, 3);
BOOST_REQUIRE_THROW(pdu.set_reason(25), odil::Exception);
}
|