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

test-cookie.cc

00001 /*
00002 *  Name:         test-cookie.cc
00003 *  Author:       Francisco Rodrigo Escobedo Robles
00004 *  Contributor:  Rafael Jesus Alcantara Perez
00005 *  Summary:      HTTP Cookie testing
00006 *  Date:         $Date: 2003/04/14 00:18:35 $
00007 *  Revision:     $Revision: 1.1 $
00008 *
00009 *  Copyright (C) 2000-2001  Francisco Rodrigo Escobedo Robles <frer@dedalo-ing.com>
00010 *  Copyright (C) 2002       Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00011 *
00012 *  This program is free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  This program is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  You should have received a copy of the GNU General Public License
00023 *  along with this program; if not, write to the Free Software
00024 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00025 *  MA 02111-1307, USA.
00026 */
00027 
00028 #include <iostream>
00029 #include <mpcl/net/cgi/cookie.hh>
00030 #include <mpcl/text/gmt_date.hh>
00031 #include <mpcl/text/string.hh>
00032 #include <mpcl/test.h>
00033 #include <sstream>
00034 
00035 
00036 int main (void)
00037 {
00038 
00039   using mpcl::net::cgi::TCookie;
00040   using mpcl::text::TGmtDate;
00041   using mpcl::text::TString;  
00042   using std::basic_istringstream;
00043   using std::basic_ostringstream;
00044 
00045   TEST_INIT ("tests for classes 'TCookie'");
00046 
00047   basic_ostringstream<char>   tTestOutputStream;
00048   basic_istringstream<char>   tTestInputStream1 ("TestCookieName1=TestCookieValue1; TestCookieName2=TestCookieValue2");
00049   basic_istringstream<char>   tTestInputStream2 ("TestCookieName3=TestCookieValue3;TestCookieName4=TestCookieValue4;");
00050   TString                     yCookieOutputValue =
00051     "Set-Cookie: TestCookieName5=TestCookieValue5; "
00052     "expires=Fri, 31-Dec-1999 23:00:00 GMT; path=/; "
00053     "domain=testdomain.com; secure\n";
00054 
00055   TCookie   tCookieTest1 (tTestInputStream1);
00056   TCookie   tCookieTest2 ("TestCookieName1", "TestCookieValue1");
00057   TCookie   tCookieTest3 (tTestInputStream1);
00058   TCookie   tCookieTest4 ("TestCookieName2", "TestCookieValue2");
00059   TCookie   tCookieTest5 (tTestInputStream2);
00060   TCookie   tCookieTest6 ("TestCookieName3", "TestCookieValue3");
00061   TCookie   tCookieTest7 (tTestInputStream2);
00062   TCookie   tCookieTest8 ("TestCookieName4", "TestCookieValue4");
00063   TCookie   tCookieTest9 ( "TestCookieName5"              ,
00064                               "TestCookieValue5"             ,
00065                               TGmtDate (2000, 1, 1, 0, 0, 0) ,
00066                               "/"                            ,
00067                               "testdomain.com"               ,
00068                               true                           );
00069 
00070   TEST_NUMBERS (true, ( tCookieTest1 == tCookieTest2 ) );
00071   TEST_NUMBERS (true, ( tCookieTest3 == tCookieTest4 ) );
00072   TEST_NUMBERS (true, ( tCookieTest5 == tCookieTest6 ) );
00073   TEST_NUMBERS (true, ( tCookieTest7 == tCookieTest8 ) );
00074 
00075   tTestOutputStream << tCookieTest9;
00076 
00077   TEST_NUMBERS (true, ( tTestOutputStream.str() == yCookieOutputValue ));
00078   TEST_MEMORY_STATUS;
00079   TEST_RETURN_CODE;
00080 
00081 }  // main()

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18