GnuCash 2.4.99
test-gnc-date.c
00001 
00002 /********************************************************************
00003  * test-gnc-date.c: GLib g_test test suite for gnc-date.h functions *
00004  * Copyright 2011 Christian Stimming                *
00005  * Copyright 2011 John Ralls <jralls@ceridwen.us>                   *
00006  *                                                                  *
00007  * This program is free software; you can redistribute it and/or    *
00008  * modify it under the terms of the GNU General Public License as   *
00009  * published by the Free Software Foundation; either version 2 of   *
00010  * the License, or (at your option) any later version.              *
00011  *                                                                  *
00012  * This program is distributed in the hope that it will be useful,  *
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00015  * GNU General Public License for more details.                     *
00016  *                                                                  *
00017  * You should have received a copy of the GNU General Public License*
00018  * along with this program; if not, contact:                        *
00019  *                                                                  *
00020  * Free Software Foundation           Voice:  +1-617-542-5942       *
00021  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00022  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00023 \********************************************************************/
00024 #include "config.h"
00025 #include <string.h>
00026 #include <glib.h>
00027 #include <unittest-support.h>
00028 #include "qof.h"
00029 #include "qofbook-p.h"
00030 #include "qofbookslots.h"
00031 
00032 static const gchar *suitename = "/qof/gnc-date";
00033 void test_suite_gnc_date ( void );
00034 
00035 typedef struct
00036 {
00037 } Fixture;
00038 
00039 static void
00040 setup( Fixture *fixture, gconstpointer pData )
00041 {
00042 }
00043 
00044 static void
00045 teardown( Fixture *fixture, gconstpointer pData )
00046 {
00047 }
00048 
00049 static void
00050 test_gnc_date_dmy2gdate( void )
00051 {
00052     GDate *p_gdate;
00053     GDate gdate;
00054     p_gdate = g_date_new_dmy(1, 2, 2011);
00055     gdate = gnc_dmy2gdate(1, 2, 2011);
00056     g_assert(g_date_compare(&gdate, p_gdate) == 0);
00057     gdate = gnc_dmy2gdate(2, 2, 2011);
00058     g_assert(g_date_compare(&gdate, p_gdate) > 0);
00059     g_date_subtract_days(&gdate, 1);
00060     g_assert(g_date_compare(&gdate, p_gdate) == 0);
00061     g_date_free(p_gdate);
00062 }
00063 
00064 void
00065 test_suite_gnc_date ( void )
00066 {
00067     GNC_TEST_ADD_FUNC( suitename, "dmy2gdate", test_gnc_date_dmy2gdate);
00068 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines