[grisbi-cvs] grisbi/src/tests gsb_data_account_cunit.c, 1.1, 1.2 utils_dates_cunit.c, 1.1, 1.2

Mathias Lorente m-lorente at users.sourceforge.net
Thu May 13 20:38:13 CEST 2010


Update of /cvsroot/grisbi/grisbi/src/tests
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25823/src/tests

Modified Files:
	gsb_data_account_cunit.c utils_dates_cunit.c 
Log Message:
Hunt memory leak. Work in progress...

Index: utils_dates_cunit.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/tests/utils_dates_cunit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- utils_dates_cunit.c	4 May 2010 20:58:26 -0000	1.1
+++ utils_dates_cunit.c	13 May 2010 18:38:11 -0000	1.2
@@ -81,6 +81,7 @@
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(1, g_date_get_month(date));
             CU_ASSERT_EQUAL(2, g_date_get_day(date));
+            g_date_free( date );
 
             // invalid day
             CU_ASSERT_EQUAL ( NULL, gsb_parse_date_string ( "02/30/2009" ) );
@@ -93,16 +94,19 @@
             CU_ASSERT_EQUAL(2008, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(29, g_date_get_day(date));
+            g_date_free( date );
 
             date = gsb_parse_date_string ( "02/28/2009" );
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(28, g_date_get_day(date));
+            g_date_free( date );
 
             date = gsb_parse_date_string ( "12/31/2009" );
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(12, g_date_get_month(date));
             CU_ASSERT_EQUAL(31, g_date_get_day(date));
+            g_date_free( date );
 
             // invalid day
             CU_ASSERT_EQUAL ( NULL, gsb_parse_date_string ( "12/32/2009" ) );
@@ -130,6 +134,7 @@
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(1, g_date_get_day(date));
+            g_date_free( date );
 
             // invalid day
             CU_ASSERT_EQUAL ( NULL, gsb_parse_date_string ( "30/02/2009" ) );
@@ -142,16 +147,19 @@
             CU_ASSERT_EQUAL(2008, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(29, g_date_get_day(date));
+            g_date_free( date );
 
             date = gsb_parse_date_string ( "28/02/2009" );
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(28, g_date_get_day(date));
+            g_date_free( date );
 
             date = gsb_parse_date_string ( "31/12/2009" );
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(12, g_date_get_month(date));
             CU_ASSERT_EQUAL(31, g_date_get_day(date));
+            g_date_free( date );
 
             // invalid day
             CU_ASSERT_EQUAL ( NULL, gsb_parse_date_string ( "32/12/2009" ) );
@@ -173,6 +181,7 @@
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(1, g_date_get_day(date));
+            g_date_free( date );
 
             // invalid day
             CU_ASSERT_EQUAL ( NULL, gsb_parse_date_string ( "02/30/2009" ) );
@@ -185,16 +194,19 @@
             CU_ASSERT_EQUAL(2008, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(29, g_date_get_day(date));
+            g_date_free( date );
 
             date = gsb_parse_date_string ( "02/28/2009" );
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(2, g_date_get_month(date));
             CU_ASSERT_EQUAL(28, g_date_get_day(date));
+            g_date_free( date );
 
             date = gsb_parse_date_string ( "12/31/2009" );
             CU_ASSERT_EQUAL(2009, g_date_get_year(date));
             CU_ASSERT_EQUAL(12, g_date_get_month(date));
             CU_ASSERT_EQUAL(31, g_date_get_day(date));
+            g_date_free( date );
 
             // invalid day
             CU_ASSERT_EQUAL ( NULL, gsb_parse_date_string ( "12/32/2009" ) );

Index: gsb_data_account_cunit.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/tests/gsb_data_account_cunit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gsb_data_account_cunit.c	4 May 2010 20:58:26 -0000	1.1
+++ gsb_data_account_cunit.c	13 May 2010 18:38:11 -0000	1.2
@@ -77,20 +77,20 @@
     CU_ASSERT_EQUAL(TRUE, gsb_data_currency_set_floating_point(cur_number, 2));
     CU_ASSERT_EQUAL(TRUE, gsb_data_account_set_currency(account_number, cur_number));
     
-    gint tr_number = gsb_data_transaction_new_transaction(account_number);
-    CU_ASSERT_EQUAL(1, tr_number);
+    gint tr_number_1 = gsb_data_transaction_new_transaction(account_number);
+    CU_ASSERT_EQUAL(1, tr_number_1);
     gsb_real amount = { 2100000021, 2 };
-    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_amount(tr_number, amount));
-    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_date(tr_number, date));
+    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_amount(tr_number_1, amount));
+    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_date(tr_number_1, date));
     gsb_real balance = gsb_data_account_calculate_current_and_marked_balances(account_number);
     CU_ASSERT_EQUAL(2100000021, balance.mantissa);
     CU_ASSERT_EQUAL(2, balance.exponent);
     
-    tr_number = gsb_data_transaction_new_transaction(account_number);
-    CU_ASSERT_EQUAL(2, tr_number);
+    gint tr_number_2 = gsb_data_transaction_new_transaction(account_number);
+    CU_ASSERT_EQUAL(2, tr_number_2);
     amount.mantissa = 100000000;
-    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_amount(tr_number, amount));
-    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_date(tr_number, date));
+    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_amount(tr_number_2, amount));
+    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_date(tr_number_2, date));
     balance = gsb_data_account_calculate_current_and_marked_balances(account_number);
     /* Lose of precision but no overflow */
     /* Previous test
@@ -100,16 +100,22 @@
     CU_ASSERT_EQUAL(220000002, balance.mantissa);
     CU_ASSERT_EQUAL(1, balance.exponent);
     
-    tr_number = gsb_data_transaction_new_transaction(account_number);
-    CU_ASSERT_EQUAL(3, tr_number);
+    gint tr_number_3 = gsb_data_transaction_new_transaction(account_number);
+    CU_ASSERT_EQUAL(3, tr_number_3);
     amount.mantissa = -100000000;
-    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_amount(tr_number, amount));
-    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_date(tr_number, date));
+    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_amount(tr_number_3, amount));
+    CU_ASSERT_EQUAL(TRUE, gsb_data_transaction_set_date(tr_number_3, date));
     balance = gsb_data_account_calculate_current_and_marked_balances(account_number);
     CU_ASSERT_EQUAL(210000002, balance.mantissa);
     CU_ASSERT_EQUAL(1, balance.exponent);
 
     g_date_free(date);
+    /*
+    gsb_data_transaction_remove_transaction( tr_number_3 );
+    gsb_data_transaction_remove_transaction( tr_number_2 );
+    gsb_data_transaction_remove_transaction( tr_number_1 );
+    */
+    gsb_data_account_delete( account_number );
 }
 
 CU_pSuite gsb_data_account_cunit_create_suite()



More information about the cvs mailing list