reSIProcate/stack  9694
Functions
testMessageWaiting.cxx File Reference
#include "resip/stack/MessageWaitingContents.hxx"
#include "resip/stack/HeaderFieldValue.hxx"
#include "rutil/ParseBuffer.hxx"
#include <iostream>
Include dependency graph for testMessageWaiting.cxx:

Go to the source code of this file.

Functions

int main ()

Function Documentation

int main ( void  )

Definition at line 10 of file testMessageWaiting.cxx.

References resip::MessageWaitingContents::clone(), resip::Data::data(), resip::MessageWaitingContents::exists(), resip::MessageWaitingContents::hasMessages(), resip::MessageWaitingContents::header(), resip::Data::size(), resip::ParseBuffer::skipChar(), and type.

{
   {
      const Data txt("s\r\nk");
      ParseBuffer pb(txt.data(), txt.size());
      pb.skipChar();

      assert(*skipSipLWS(pb) == '\r');
   }

   {
      const Data txt("s\r\n\r\nk");
      ParseBuffer pb(txt.data(), txt.size());
      pb.skipChar();

      assert(skipSipLWS(pb) == txt.data()+1);
   }
   {
      cerr << "Test unparsed copy constructor" << endl;
   
      const Data txt("Messages-Waiting: yes\r\n"
                     "voice-message: 7/0\r\n");

      HeaderFieldValue hfv(txt.data(), txt.size());
      Mime type("text", "data");
      MessageWaitingContents mwb(hfv, type);

      MessageWaitingContents* mwb2 =
         dynamic_cast<MessageWaitingContents*>(mwb.clone());

      assert(mwb2->header(mw_voice).newCount() == 7);
      assert(mwb2->header(mw_voice).oldCount() == 0);
   }

   {
      const Data txt("Messages-Waiting: yes\r\n");

      HeaderFieldValue hfv(txt.data(), txt.size());
      Mime type("application", "simple-message-summary");
      MessageWaitingContents mwb(hfv, type);
      
      assert(mwb.hasMessages() == true);      
   }

   {
      const Data txt("Messages-Waiting: no\r\n");

      HeaderFieldValue hfv(txt.data(), txt.size());
      Mime type("application", "simple-message-summary");
      MessageWaitingContents mwb(hfv, type);
      
      assert(mwb.hasMessages() == false);      
   }

   {
      const Data txt("Messages-Waiting: yes\r\n"
                     "Message-Account: sip:alice@vmail.example.com\r\n"
                     "Voice-Message: 4/8 (1/2)\r\n");

      HeaderFieldValue hfv(txt.data(), txt.size());
      Mime type("application", "simple-message-summary");
      MessageWaitingContents mwb(hfv, type);

      assert(mwb.header(mw_account).scheme() == "sip");
      assert(mwb.header(mw_account).user() == "alice");
      assert(mwb.header(mw_account).host() == "vmail.example.com");
      
      assert(mwb.header(mw_voice).newCount() == 4);
      assert(mwb.header(mw_voice).oldCount() == 8);
      assert(mwb.header(mw_voice).urgent() == true);
      assert(mwb.header(mw_voice).urgentNewCount() == 1);
      assert(mwb.header(mw_voice).urgentOldCount() == 2);

      assert(mwb.exists(mw_fax) == false);
   }


   {
      const Data txt("Messages-Waiting: yes\r\n"
                     "Message-Account: sip:alice@vmail.example.com\r\n"
                     "Voice-Message: 4/8 (1/2)\r\n"
                     "Fax-Message: 2/1\r\n"
                     "\r\n"
                     "Something: fine choice\r\n");

      HeaderFieldValue hfv(txt.data(), txt.size());
      Mime type("application", "simple-message-summary");
      MessageWaitingContents mwb(hfv, type);

      assert(mwb.header(mw_account).scheme() == "sip");
      assert(mwb.header(mw_account).user() == "alice");
      assert(mwb.header(mw_account).host() == "vmail.example.com");
      
      assert(mwb.header(mw_voice).newCount() == 4);
      assert(mwb.header(mw_voice).oldCount() == 8);
      assert(mwb.header(mw_voice).urgent() == true);
      assert(mwb.header(mw_voice).urgentNewCount() == 1);
      assert(mwb.header(mw_voice).urgentOldCount() == 2);

      assert(mwb.header(mw_fax).newCount() == 2);
      assert(mwb.header(mw_fax).oldCount() == 1);
      assert(mwb.header(mw_fax).urgent() == false);
      
      assert(mwb.header(Data("Something")) == Data("fine choice"));

      assert(mwb.exists(mw_fax) == true);
   }      

   cerr << "All OK" << endl;
   return 0;
}

Here is the call graph for this function: