00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <spl/Debug.h>
00018 #include <spl/Date.h>
00019 #include <spl/Log.h>
00020
00021 #ifdef DEBUG
00022
00023 static void _TestDate1()
00024 {
00025 Date dt;
00026 DEBUG_CLEAR_MEM_CHECK_POINTS();
00027 DEBUG_DUMP_MEM_LEAKS();
00028 UNIT_ASSERT_MEM_NOTED("Date test 1.0");
00029
00030 UNIT_ASSERT("Date now", dt.Year() > 2007);
00031
00032 Log::SWriteOkFail( "Date test 1" );
00033 }
00034
00035 static void _TestDate2()
00036 {
00037 Date dt(1999, 1, 31);
00038
00039 UNIT_ASSERT("Date y", dt.Year() == 1999);
00040 UNIT_ASSERT("Date m", dt.Month() == 1);
00041 UNIT_ASSERT("Date d", dt.Day() == 31);
00042 UNIT_ASSERT("Date dow", dt.DayOfWeek() == 0);
00043 UNIT_ASSERT("Date leap year", !dt.IsLeapYear());
00044 UNIT_ASSERT("Date do year", dt.DayOfYear() == 31);
00045
00046 time_t t = dt.ToSysTime();
00047 Date dt2(t);
00048
00049 UNIT_ASSERT("Date time_t", dt.Equals(dt2));
00050
00051 DEBUG_CLEAR_MEM_CHECK_POINTS();
00052 DEBUG_DUMP_MEM_LEAKS();
00053 UNIT_ASSERT_MEM_NOTED("Date test 2.0");
00054
00055 Log::SWriteOkFail( "Date test 2" );
00056 }
00057
00058 static void _TestDate3()
00059 {
00060 Date dt(1999, 12, 31);
00061 Date dt2(2000, 1, 31);
00062
00063 UNIT_ASSERT("Date leap year", dt2.IsLeapYear());
00064 UNIT_ASSERT("Date equal", !dt.Equals(dt2));
00065 UNIT_ASSERT("Date diff", 31 == dt2.DiffInDays(&dt));
00066
00067 DEBUG_CLEAR_MEM_CHECK_POINTS();
00068 DEBUG_DUMP_MEM_LEAKS();
00069 UNIT_ASSERT_MEM_NOTED("Date test 3.0");
00070
00071 Log::SWriteOkFail( "Date test 3" );
00072 }
00073
00074 void _TestDate()
00075 {
00076 _TestDate1();
00077 _TestDate2();
00078 _TestDate3();
00079 }
00080
00081 #endif