GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test-gnc-numeric.c
1 /********************************************************************
2  * test_qofbackend.c: GLib g_test test suite for qofbackend. *
3  * Copyright 2011 John Ralls <[email protected]> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA [email protected] *
21 \********************************************************************/
22 #include "config.h"
23 #include <string.h>
24 #include <glib.h>
25 #include <qof.h>
26 #include <unittest-support.h>
27 
28 static const gchar *suitename = "/qof/gnc_numeric";
29 
30 static void
31 test_gnc_numeric_add (void)
32 {
33  gnc_numeric a = { 123456789987654321, 1000000000 };
34  gnc_numeric b = { 65432198765432198, 100000000 };
35  gnc_numeric goal_ab = { 777778777641976301, 1000000000 };
36  gnc_numeric result;
37 
38  result = gnc_numeric_add (a, b, GNC_DENOM_AUTO,
40  g_assert (gnc_numeric_equal (result, goal_ab));
41 }
42 
43 void
44 test_suite_gnc_numeric ( void )
45 {
46  GNC_TEST_ADD_FUNC( suitename, "gnc-numeric add", test_gnc_numeric_add );
47 }
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
#define GNC_DENOM_AUTO
Definition: gnc-numeric.h:246