1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/glib/tsrc/BC/src/date_test.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,84 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.6 +*
1.7 +* This library is free software; you can redistribute it and/or
1.8 +* modify it under the terms of the GNU Lesser General Public
1.9 +* License as published by the Free Software Foundation; either
1.10 +* version 2 of the License, or (at your option) any later version.
1.11 +*
1.12 +* This library is distributed in the hope that it will be useful,
1.13 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.15 +* Lesser General Public License for more details.
1.16 +*
1.17 +* You should have received a copy of the GNU Lesser General Public
1.18 +* License along with this library; if not, write to the
1.19 +* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.20 +* Boston, MA 02111-1307, USA.
1.21 +*
1.22 +* Description:
1.23 +*
1.24 +*/
1.25 +
1.26 +
1.27 +
1.28 +#undef G_DISABLE_ASSERT
1.29 +#undef G_LOG_DOMAIN
1.30 +
1.31 +#include <stdio.h>
1.32 +#include <string.h>
1.33 +#include "glib.h"
1.34 +
1.35 +#ifdef SYMBIAN
1.36 +#include "mrt2_glib2_test.h"
1.37 +#endif /*SYMBIAN*/
1.38 +
1.39 +
1.40 +int main (int argc,char *argv[])
1.41 +{
1.42 +
1.43 + GDate *date1,*date2,*date;
1.44 +
1.45 + #ifdef SYMBIAN
1.46 + g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
1.47 + #endif /*SYMBIAN*/
1.48 +
1.49 + date = g_date_new_dmy(1,G_DATE_MAY,2003);
1.50 + date1 = g_date_new_dmy(1,G_DATE_MAY,2006);
1.51 + date2 = g_date_new_dmy(31,G_DATE_MAY,2006);
1.52 +
1.53 + g_assert(g_date_days_between(date1,date2) == 30);
1.54 + g_assert(g_date_days_between(date2,date1) < 0);
1.55 +
1.56 + date1 = g_date_new_dmy(1,G_DATE_MAY,2006);
1.57 +
1.58 + g_assert(g_date_is_first_of_month(date1));
1.59 + g_assert(g_date_is_last_of_month(date2));
1.60 +
1.61 + g_date_order(date2,date1);
1.62 +
1.63 + g_assert(date2->day == 1 && date2->month == 5 && date2->year == 2006);
1.64 + g_assert(date1->day == 31 && date1->month == 5 && date1->year == 2006);
1.65 +
1.66 + g_date_set_month(date1,G_DATE_JULY);
1.67 + g_date_set_year(date1,2007);
1.68 +
1.69 + g_assert(date1->month == 7);
1.70 + g_assert(date1->year == 2007);
1.71 +
1.72 + g_date_clamp(date,date2,date1);
1.73 +
1.74 + g_assert(date->day == 1 && date->month == 5 && date->year == 2006);
1.75 +
1.76 + g_date_set_year(date,2008);
1.77 +
1.78 + g_date_clamp(date,date2,date1);
1.79 +
1.80 + g_assert(date->day == 31 && date->month == 7 && date->year == 2007);
1.81 +
1.82 + #if SYMBIAN
1.83 + testResultXml("date_test");
1.84 + #endif /* EMULATOR */
1.85 +
1.86 + return 0;
1.87 +}
1.88 \ No newline at end of file