reSIProcate/stack  9694
Functions
testPlainContents.cxx File Reference
#include "resip/stack/PlainContents.hxx"
#include <iostream>
#include <fstream>
Include dependency graph for testPlainContents.cxx:

Go to the source code of this file.

Functions

void setContentsHeaders (Contents &contents)
void leakCheck (bool verbose)
int main (int argc, char *argv[])

Function Documentation

void leakCheck ( bool  verbose)

Definition at line 25 of file testPlainContents.cxx.

References resip::Data::data(), EncodeStream, resipCout, resip::resipFastNull, setContentsHeaders(), resip::Data::size(), and type.

Referenced by main().

{

    Data original;
    Data alternate;

    { // WIN32 workaround
        for (int i = 0 ; i < 100 ; ++i)
        {
            original += "Original Body by Fischer. -- ";
            alternate += "Alternate Body by CheapStandinCo. -- ";
        }
    }

#ifndef WIN32
#ifdef RESIP_USE_STL_STREAMS
    ofstream devnull("/dev/null");
    ostream& os(verbose?cout:devnull);
#else
    EncodeStream &os(verbose?resipCout:resipFastNull);
#endif
    assert(os.good());
#endif

    for(int i = 0 ; i < 100 ; ++i)
    {
          Mime type("text", "plain");

          HeaderFieldValue ohfv(original.data(), original.size());
          PlainContents originalContents(ohfv, type);
          setContentsHeaders(originalContents);

          HeaderFieldValue ahfv(alternate.data(),alternate.size());
          PlainContents alternateContents(ahfv, type);
          setContentsHeaders(alternateContents);

#ifndef WIN32
          if (verbose && i == 0)
          {
              originalContents.encodeHeaders(os);
              originalContents.encode(os);
              os << endl;
              alternateContents.encodeHeaders(os);
              alternateContents.encode(os);
              os << endl;
          }
#endif

          // clobber the content-disposition mDisposition variable
          alternateContents = originalContents;

#if 0
          alternateContents.encodeHeaders(os);
          alternateContents.encode(os);
          os << endl;
#endif
    }
}

Here is the call graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 85 of file testPlainContents.cxx.

References resip::Data::data(), leakCheck(), resip::Data::size(), resip::PlainContents::text(), and type.

{
   {
      const Data txt("some plain text");

      HeaderFieldValue hfv(txt.data(), txt.size());
      Mime type("text", "plain");
      PlainContents pc(hfv, type);

      cerr << pc.text() << endl;

      assert(pc.text() == "some plain text");
   }

   leakCheck(argc > 1);

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

Here is the call graph for this function:

void setContentsHeaders ( Contents contents)

Definition at line 14 of file testPlainContents.cxx.

References resip::Contents::header().

Referenced by leakCheck().

{
    contents.header(h_ContentDisposition).value() = "content-disposition-phrase";
    contents.header(h_ContentDescription).value() = "content-description-phrase";
    contents.header(h_ContentTransferEncoding).value() = "content-transfer-encoding-phrase";
    const char *lang[] = { "en_CA","en_GB","en_US","fr_CA","fr_FR","es_ES.iso88591" };
    for(size_t i = 0 ; i < sizeof(lang)/sizeof(*lang); ++i)
        contents.header(h_ContentLanguages).push_back(Token(lang[i]));
}

Here is the call graph for this function: