Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

CDATATest.cpp

00001 //============================================================================
00002 // Project:       Jabber Universal Document Objects (Judo)
00003 // Filename:      CDATATest.cpp
00004 // Description:   judo::CDATA unit tests
00005 // Created at:    Tue Jul  3 13:06:11 2001
00006 // Modified at:   Mon Jul 30 18:06:35 2001
00007 //
00008 //   License:
00009 // 
00010 // The contents of this file are subject to the Jabber Open Source License
00011 // Version 1.0 (the "License").  You may not copy or use this file, in either
00012 // source code or executable form, except in compliance with the License.  You
00013 // may obtain a copy of the License at http://www.jabber.com/license/ or at
00014 // http://www.opensource.org/.  
00015 //
00016 // Software distributed under the License is distributed on an "AS IS" basis,
00017 // WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
00018 // for the specific language governing rights and limitations under the
00019 // License.
00020 //
00021 //   Copyrights
00022 //
00023 // Portions created by or assigned to Jabber.com, Inc. are 
00024 // Copyright (c) 1999-2001 Jabber.com, Inc.  All Rights Reserved.  
00025 // 
00026 // $Id: CDATATest.cpp,v 1.2 2002/07/13 19:30:22 temas Exp $
00027 //============================================================================
00028 
00029 #include "judo.hpp"
00030 #include "judo_test.hpp"
00031 using namespace judo;
00032 
00033 #include <iostream>
00034 using namespace std;
00035 
00036 Test* CDATATest::getTestSuite()
00037 {
00038     TestSuite* s = new TestSuite();
00039     s->addTest(new TestCaller<CDATATest>("testing construction",
00040                                          &CDATATest::construct));
00041     s->addTest(new TestCaller<CDATATest>("testing setText",
00042                                          &CDATATest::setText));
00043     s->addTest(new TestCaller<CDATATest>("testing appendText",
00044                                          &CDATATest::appendText));
00045     s->addTest(new TestCaller<CDATATest>("testing getText",
00046                                          &CDATATest::getText));
00047     s->addTest(new TestCaller<CDATATest>("testing toString",
00048                                          &CDATATest::CDATAtoString));
00049 
00050 
00051     return s;
00052 }
00053 
00054 void CDATATest::construct()
00055 {
00056     {
00057         CDATA c("Hello, world!", strlen("Hello, world!"));
00058         Assert(c._text == "Hello, world!");
00059     }
00060 
00061     {
00062         CDATA c("&amp; &apos; &quot; &lt; &gt;",strlen("&amp; &apos; &quot; &lt; &gt;"), true);
00063         cerr << c._text << endl;
00064         Assert(c._text == "& ' \" < >");
00065     }
00066 
00067 }
00068 
00069 
00070 void CDATATest::setText()
00071 {
00072     CDATA c("Hello, world!", strlen("Hello, world!"));
00073 
00074     c.setText("Yo buddy!", 9);
00075 
00076     Assert(c._text == "Yo buddy!");
00077 }
00078 
00079 void CDATATest::appendText()
00080 {
00081     CDATA c("Hello, world!", strlen("Hello, world!"));
00082 
00083     c.appendText(" Goodbye world!", 15);
00084 
00085     Assert(c._text == "Hello, world! Goodbye world!");
00086 }
00087 
00088 void CDATATest::getText()
00089 {
00090     CDATA c("Hello, world!", strlen("Hello, world!"));
00091 
00092     Assert(c.getText() == "Hello, world!");
00093 }
00094 
00095 void CDATATest::CDATAtoString()
00096 {
00097     CDATA c("Hello, world!", strlen("Hello, world!"));
00098 
00099     string s = c.toString();
00100 
00101     Assert(s == "Hello, world!");
00102 }
00103 

Generated on Thu Jul 24 13:31:50 2003 for jabberoo by doxygen1.3-rc3