r21563 - gnucash/trunk/src/libqof/qof/test - Add unittest for gnc_dmy2gdate() function to verify the correct behaviour of the by-value returned value.
Christian Stimming
cstim at code.gnucash.org
Sun Nov 13 15:39:54 EST 2011
Author: cstim
Date: 2011-11-13 15:39:53 -0500 (Sun, 13 Nov 2011)
New Revision: 21563
Trac: http://svn.gnucash.org/trac/changeset/21563
Added:
gnucash/trunk/src/libqof/qof/test/test-gnc-date.c
Modified:
gnucash/trunk/src/libqof/qof/test/Makefile.am
gnucash/trunk/src/libqof/qof/test/test-qof.c
Log:
Add unittest for gnc_dmy2gdate() function to verify the correct behaviour of the by-value returned value.
Modified: gnucash/trunk/src/libqof/qof/test/Makefile.am
===================================================================
--- gnucash/trunk/src/libqof/qof/test/Makefile.am 2011-11-11 21:58:36 UTC (rev 21562)
+++ gnucash/trunk/src/libqof/qof/test/Makefile.am 2011-11-13 20:39:53 UTC (rev 21563)
@@ -9,6 +9,7 @@
MODULEPATH = src/libqof/qof
test_qof_SOURCES = \
+ test-gnc-date.c \
test-qof.c \
test-qofbook.c \
test-qofinstance.c \
Copied: gnucash/trunk/src/libqof/qof/test/test-gnc-date.c (from rev 21562, gnucash/trunk/src/libqof/qof/test/test-qof.c)
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-gnc-date.c (rev 0)
+++ gnucash/trunk/src/libqof/qof/test/test-gnc-date.c 2011-11-13 20:39:53 UTC (rev 21563)
@@ -0,0 +1,68 @@
+
+/********************************************************************
+ * test-gnc-date.c: GLib g_test test suite for gnc-date.h functions *
+ * Copyright 2011 Christian Stimming *
+ * Copyright 2011 John Ralls <jralls at ceridwen.us> *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact: *
+ * *
+ * Free Software Foundation Voice: +1-617-542-5942 *
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
+ * Boston, MA 02110-1301, USA gnu at gnu.org *
+\********************************************************************/
+#include "config.h"
+#include <string.h>
+#include <glib.h>
+#include "qof.h"
+#include "qofbook-p.h"
+#include "qofbookslots.h"
+#include "test-stuff.h"
+
+static const gchar *suitename = "/qof/gnc-date";
+void test_suite_gnc_date ( void );
+
+typedef struct
+{
+} Fixture;
+
+static void
+setup( Fixture *fixture, gconstpointer pData )
+{
+}
+
+static void
+teardown( Fixture *fixture, gconstpointer pData )
+{
+}
+
+static void
+test_gnc_date_dmy2gdate( void )
+{
+ GDate *p_gdate;
+ GDate gdate;
+ p_gdate = g_date_new_dmy(1, 2, 2011);
+ gdate = gnc_dmy2gdate(1, 2, 2011);
+ g_assert(g_date_compare(&gdate, p_gdate) == 0);
+ gdate = gnc_dmy2gdate(2, 2, 2011);
+ g_assert(g_date_compare(&gdate, p_gdate) > 0);
+ g_date_subtract_days(&gdate, 1);
+ g_assert(g_date_compare(&gdate, p_gdate) == 0);
+ g_date_free(p_gdate);
+}
+
+void
+test_suite_gnc_date ( void )
+{
+ GNC_TEST_ADD_FUNC( suitename, "dmy2gdate", test_gnc_date_dmy2gdate);
+}
Modified: gnucash/trunk/src/libqof/qof/test/test-qof.c
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-qof.c 2011-11-11 21:58:36 UTC (rev 21562)
+++ gnucash/trunk/src/libqof/qof/test/test-qof.c 2011-11-13 20:39:53 UTC (rev 21563)
@@ -30,6 +30,7 @@
extern void test_suite_kvp_frame();
extern void test_suite_qofobject();
extern void test_suite_qofsession();
+extern void test_suite_gnc_date();
int
main (int argc,
@@ -45,6 +46,7 @@
test_suite_kvp_frame();
test_suite_qofobject();
test_suite_qofsession();
+ test_suite_gnc_date();
return g_test_run( );
}
More information about the gnucash-changes
mailing list