00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 }