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 <mpcl/text/gmt_date.hh>
00029 #include <mpcl/text/local_date.hh>
00030 #include <mpcl/test.h>
00031
00032
00034 int main (void)
00035 {
00036
00037 using mpcl::text::IDate;
00038 using mpcl::text::TGmtDate;
00039 using mpcl::text::TLocalDate;
00040 using mpcl::TConstraintException;
00041
00042 bool gExceptionTest;
00043 TGmtDate tEmptyGmtDate (IDate::eEmpty);
00044 TGmtDate tGmtDate1999 (1999, 12, 31, 23, 59, 59);
00045 TGmtDate tGmtDate2000 (2000, 1, 1, 0, 0, 0);
00046 TLocalDate tLocalDate1999 (1999, 12, 31, 23, 59, 59);
00047 TLocalDate tLocalDate2000 (2000, 1, 1, 0, 0, 0);
00048
00049 TEST_INIT ("tests for classes 'TGmtDate' and 'TLocalDate'");
00050
00051
00052
00053
00054 TEST_NUMBERS (false, ( tGmtDate1999 == tGmtDate2000 ));
00055 TEST_NUMBERS (false, ( tGmtDate1999 > tGmtDate2000 ));
00056 TEST_NUMBERS (false, ( tGmtDate1999 >= tGmtDate2000 ));
00057 TEST_NUMBERS (false, ( tLocalDate1999 == tLocalDate2000 ));
00058 TEST_NUMBERS (false, ( tLocalDate1999 > tLocalDate2000 ));
00059 TEST_NUMBERS (false, ( tLocalDate1999 >= tLocalDate2000 ));
00060 TEST_NUMBERS (true, ( tGmtDate1999 != tGmtDate2000 ));
00061 TEST_NUMBERS (true, ( tGmtDate1999 < tGmtDate2000 ));
00062 TEST_NUMBERS (true, ( tGmtDate1999 <= tGmtDate2000 ));
00063 TEST_NUMBERS (true, ( tLocalDate1999 != tLocalDate2000 ));
00064 TEST_NUMBERS (true, ( tLocalDate1999 < tLocalDate2000 ));
00065 TEST_NUMBERS (true, ( tLocalDate1999 <= tLocalDate2000 ));
00066
00067
00068
00069
00070 TEST_NUMBERS (true, ( tGmtDate1999.addSeconds (1) == tGmtDate2000 ));
00071 TEST_NUMBERS (true, ( tLocalDate1999.addSeconds (1) == tLocalDate2000 ))
00072 TEST_NUMBERS (false, ( tGmtDate1999 < tGmtDate2000 ));
00073 TEST_NUMBERS (false, ( tLocalDate1999 < tLocalDate2000 ));
00074
00075
00076
00077
00078 tGmtDate1999.set (1999, 12, 31, 23, 59, 59);
00079 tGmtDate2000.set (2000, 1, 1, 0, 0, 0);
00080 TEST_NUMBERS (true, tGmtDate1999.in (tGmtDate1999, tGmtDate1999));
00081 TEST_NUMBERS (false, tGmtDate1999.in (tGmtDate2000, tGmtDate2000));
00082 TEST_NUMBERS (false, tGmtDate1999.in (tGmtDate2000, tGmtDate1999));
00083 TEST_NUMBERS (true, tGmtDate1999.in (TGmtDate (1970, 1, 1), tGmtDate2000));
00084 TEST_NUMBERS (true, tGmtDate1999.in (TGmtDate (1970, 1, 1), tGmtDate1999));
00085 TEST_NUMBERS (false, tGmtDate2000.in (tGmtDate1999, tGmtDate1999));
00086 TEST_NUMBERS (true, tGmtDate2000.in (tGmtDate2000, tGmtDate2000));
00087 TEST_NUMBERS (false, tGmtDate2000.in (tGmtDate2000, tGmtDate1999));
00088 TEST_NUMBERS (true, tGmtDate2000.in (TGmtDate (1970, 1, 1), tGmtDate2000));
00089 TEST_NUMBERS (false, tGmtDate2000.in (TGmtDate (1970, 1, 1), tGmtDate1999));
00090
00091
00092
00093
00094 try
00095 {
00096 TEST_NUMBERS (false, tGmtDate2000.in (tEmptyGmtDate, tEmptyGmtDate));
00097 TEST_FAIL;
00098 }
00099 catch (const TConstraintException& rktEXCEPTION)
00100 {
00101 TEST_PASS;
00102 }
00103
00104
00105
00106
00107 try
00108 {
00109 TEST_NUMBERS (false, tEmptyGmtDate.in (tGmtDate1999, tGmtDate2000));
00110 TEST_FAIL;
00111 }
00112 catch (const TConstraintException& rktEXCEPTION)
00113 {
00114 TEST_PASS;
00115 }
00116
00117
00118
00119
00120 try
00121 {
00122 tEmptyGmtDate.addSeconds (1);
00123 TEST_FAIL;
00124 }
00125 catch (const TConstraintException& rktEXCEPTION)
00126 {
00127 TEST_PASS;
00128 }
00129 try
00130 {
00131
00132
00133
00134 gExceptionTest = ( tEmptyGmtDate == tGmtDate2000 );
00135 TEST_FAIL;
00136 }
00137 catch (const TConstraintException& rktEXCEPTION)
00138 {
00139 TEST_PASS;
00140 }
00141 try
00142 {
00143
00144
00145
00146 gExceptionTest = ( tEmptyGmtDate < tGmtDate2000 );
00147 TEST_FAIL;
00148 }
00149 catch (const TConstraintException& rktEXCEPTION)
00150 {
00151 TEST_PASS;
00152 }
00153
00154 TEST_MEMORY_STATUS;
00155 TEST_RETURN_CODE;
00156
00157 }