Exemple #1
0
void ABTMessageTest::test_xml(void)
{
    using namespace maxmm::ma;
    {
        typedef ABTMessage<uint32_t> Msg;
    
        Msg msg;
        msg.make_ok();
        msg.ok().agent_assignment().value() = 2;
        msg.ok().agent_assignment().agent_id() = AgentId(1);

        xmlpp::Document document;
        document.create_root_node("abt_message");
        XmlEncoder encoder(document);

        msg.encode(encoder);

        std::cout << document.write_to_string() << std::endl;

    }
    
    {
        typedef ABTMessage<uint32_t> Msg;
    
        Msg msg;
        msg.make_nogood().nogoods().push_back(AgentAssignment<uint32_t>());
        
        msg.nogood().nogoods().push_back(AgentAssignment<uint32_t>());

        msg.nogood().nogoods().at(0).value() = 2;
        msg.nogood().nogoods().at(1).value() = 3;
        msg.nogood().nogoods().at(0).agent_id() = ma::AgentId(0);
        msg.nogood().nogoods().at(1).agent_id() = ma::AgentId(1);

        
        xmlpp::Document document;
        document.create_root_node("abt_message");
        XmlEncoder encoder(document);

        msg.encode(encoder);

        std::cout << document.write_to_string() << std::endl;

    }


}
Exemple #2
0
void ABTMessageTest::test_accessors(void)
{
    using namespace maxmm::ma;
    {
        typedef ABTMessage<uint32_t> Msg;
    
        Msg msg;
        msg.make_ok();
        msg.ok().agent_assignment().value() = 2;
        msg.ok().agent_assignment().agent_id() = ma::AgentId(1);
        CPPUNIT_ASSERT_EQUAL(uint32_t(2), msg.ok().agent_assignment().value());
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), msg.ok().agent_assignment().agent_id().id());
        
        Msg msg2;
        msg2 = msg;
    
        Msg msg3;
    }
    
    {
        typedef ABTMessage<uint32_t> Msg;
    
        Msg msg;
        msg.make_nogood().nogoods().push_back(AgentAssignment<uint32_t>());
        CPPUNIT_ASSERT_EQUAL(std::size_t(1),  msg.nogood().nogoods().size());
        
        msg.nogood().nogoods().push_back(AgentAssignment<uint32_t>());
        CPPUNIT_ASSERT_EQUAL(std::size_t(2),  msg.nogood().nogoods().size());

        msg.nogood().nogoods().at(0).value() = 2;
        msg.nogood().nogoods().at(1).value() = 3;

        CPPUNIT_ASSERT_EQUAL(uint32_t(2), msg.nogood().nogoods().at(0).value());
        CPPUNIT_ASSERT_EQUAL(uint32_t(3), msg.nogood().nogoods().at(1).value());
    }

}