os/ossrv/glib/tsrc/BC/src/date_test.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0
     3
*
sl@0
     4
* This library is free software; you can redistribute it and/or
sl@0
     5
* modify it under the terms of the GNU Lesser General Public
sl@0
     6
* License as published by the Free Software Foundation; either
sl@0
     7
* version 2 of the License, or (at your option) any later version.
sl@0
     8
*
sl@0
     9
* This library is distributed in the hope that it will be useful,
sl@0
    10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
sl@0
    11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
sl@0
    12
* Lesser General Public License for more details.
sl@0
    13
*
sl@0
    14
* You should have received a copy of the GNU Lesser General Public
sl@0
    15
* License along with this library; if not, write to the
sl@0
    16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
sl@0
    17
* Boston, MA 02111-1307, USA.
sl@0
    18
*
sl@0
    19
* Description:
sl@0
    20
*
sl@0
    21
*/
sl@0
    22
sl@0
    23
sl@0
    24
sl@0
    25
#undef G_DISABLE_ASSERT
sl@0
    26
#undef G_LOG_DOMAIN
sl@0
    27
sl@0
    28
#include <stdio.h>
sl@0
    29
#include <string.h>
sl@0
    30
#include "glib.h"
sl@0
    31
sl@0
    32
#ifdef SYMBIAN
sl@0
    33
#include "mrt2_glib2_test.h"
sl@0
    34
#endif /*SYMBIAN*/
sl@0
    35
sl@0
    36
sl@0
    37
int main (int   argc,char *argv[])
sl@0
    38
{
sl@0
    39
	
sl@0
    40
	GDate *date1,*date2,*date;
sl@0
    41
	
sl@0
    42
	#ifdef SYMBIAN
sl@0
    43
	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);
sl@0
    44
	#endif /*SYMBIAN*/
sl@0
    45
sl@0
    46
	date = g_date_new_dmy(1,G_DATE_MAY,2003);	
sl@0
    47
	date1 = g_date_new_dmy(1,G_DATE_MAY,2006);
sl@0
    48
	date2 = g_date_new_dmy(31,G_DATE_MAY,2006);
sl@0
    49
	
sl@0
    50
	g_assert(g_date_days_between(date1,date2) == 30);
sl@0
    51
	g_assert(g_date_days_between(date2,date1) < 0);
sl@0
    52
	
sl@0
    53
	date1 = g_date_new_dmy(1,G_DATE_MAY,2006);
sl@0
    54
	
sl@0
    55
	g_assert(g_date_is_first_of_month(date1));
sl@0
    56
	g_assert(g_date_is_last_of_month(date2));
sl@0
    57
	
sl@0
    58
	g_date_order(date2,date1);
sl@0
    59
	
sl@0
    60
	g_assert(date2->day == 1 && date2->month == 5 && date2->year == 2006);
sl@0
    61
	g_assert(date1->day == 31 && date1->month == 5 && date1->year == 2006);
sl@0
    62
	
sl@0
    63
	g_date_set_month(date1,G_DATE_JULY);
sl@0
    64
	g_date_set_year(date1,2007);
sl@0
    65
	
sl@0
    66
	g_assert(date1->month == 7);
sl@0
    67
	g_assert(date1->year == 2007);
sl@0
    68
	
sl@0
    69
	g_date_clamp(date,date2,date1);
sl@0
    70
	
sl@0
    71
	g_assert(date->day == 1 && date->month == 5 && date->year == 2006);
sl@0
    72
	
sl@0
    73
	g_date_set_year(date,2008);
sl@0
    74
	
sl@0
    75
	g_date_clamp(date,date2,date1);
sl@0
    76
	
sl@0
    77
	g_assert(date->day == 31 && date->month == 7 && date->year == 2007);
sl@0
    78
	
sl@0
    79
	#if SYMBIAN
sl@0
    80
  	testResultXml("date_test");
sl@0
    81
  	#endif /* EMULATOR */
sl@0
    82
	
sl@0
    83
	return 0;
sl@0
    84
}