mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'plug-test-leaks' into stable #1771
This commit is contained in:
commit
96a63f922f
@ -647,17 +647,10 @@ get_imap_info (ImapDialog *imap_dialog, Account *acc, const gchar *category, con
|
||||
// First add a child entry and pass iter to add_to_store
|
||||
gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &child, &toplevel);
|
||||
add_to_store (imap_dialog, &child, text, imapInfo);
|
||||
|
||||
// Free the members and structure
|
||||
g_free (imapInfo->head);
|
||||
g_free (imapInfo->category);
|
||||
g_free (imapInfo->match_string);
|
||||
g_free (imapInfo->count);
|
||||
g_free (imapInfo);
|
||||
}
|
||||
}
|
||||
g_free (acc_name);
|
||||
g_list_free (imap_list); // Free the List
|
||||
g_list_free_full (imap_list, (GDestroyNotify)gnc_account_imap_info_destroy); // Free the List
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,6 +114,7 @@ test_db (GNCPriceDB* db)
|
||||
failure_args ("gnc_xml_parse_file returned FALSE",
|
||||
__FILE__, __LINE__, "%d", iter);
|
||||
}
|
||||
sixtp_destroy (parser);
|
||||
}
|
||||
|
||||
g_unlink (filename1);
|
||||
|
@ -6232,6 +6232,15 @@ build_bayes (const char *suffix, KvpValue * value, GncImapInfo & imapInfo)
|
||||
imapInfo.list = g_list_prepend (imapInfo.list, imap_node);
|
||||
}
|
||||
|
||||
void gnc_account_imap_info_destroy (GncImapInfo* imapInfo)
|
||||
{
|
||||
g_free (imapInfo->head);
|
||||
g_free (imapInfo->category);
|
||||
g_free (imapInfo->match_string);
|
||||
g_free (imapInfo->count);
|
||||
g_free (imapInfo);
|
||||
}
|
||||
|
||||
GList *
|
||||
gnc_account_imap_get_info_bayes (Account *acc)
|
||||
{
|
||||
|
@ -1611,6 +1611,11 @@ typedef enum
|
||||
char *count;
|
||||
}GncImapInfo;
|
||||
|
||||
/** Clean destructor for the imap_info structure of Bayesian
|
||||
* mappings
|
||||
*/
|
||||
void gnc_account_imap_info_destroy (GncImapInfo*);
|
||||
|
||||
/** Returns a GList of structure imap_info of all Bayesian mappings for
|
||||
* required Account
|
||||
*/
|
||||
|
@ -266,6 +266,8 @@ TEST_F(ImapBayesTest, FindAccountBayes)
|
||||
root->set_path({std::string{IMAP_FRAME_BAYES} + "/" + pepper + "/" + waldo + "/" + acct2_guid}, new KvpValue{*value});
|
||||
account = gnc_account_imap_find_account_bayes(t_acc, t_list3);
|
||||
EXPECT_EQ(t_expense_account1, account);
|
||||
g_free (acct1_guid);
|
||||
g_free (acct2_guid);
|
||||
}
|
||||
|
||||
TEST_F(ImapBayesTest, AddAccountBayes)
|
||||
@ -309,6 +311,8 @@ TEST_F(ImapBayesTest, AddAccountBayes)
|
||||
qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account));
|
||||
value = root->get_slot({std::string{IMAP_FRAME_BAYES} + "/" + baz + "/" + acct2_guid});
|
||||
EXPECT_EQ(2, value->get<int64_t>());
|
||||
g_free (acct1_guid);
|
||||
g_free (acct2_guid);
|
||||
}
|
||||
|
||||
TEST_F(ImapBayesTest, ConvertBayesData)
|
||||
@ -353,6 +357,10 @@ TEST_F(ImapBayesTest, ConvertBayesData)
|
||||
value = root->get_slot({std::string{IMAP_FRAME_BAYES} + "/" + salt + "/" + acct1_guid});
|
||||
EXPECT_EQ(10, value->get<int64_t>());
|
||||
EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
|
||||
g_free (acct1_guid);
|
||||
g_free (acct2_guid);
|
||||
g_free (acct3_guid);
|
||||
g_free (acct4_guid);
|
||||
}
|
||||
|
||||
/* Tests the import map's handling of KVP delimiters */
|
||||
@ -365,6 +373,7 @@ TEST_F (ImapBayesTest, import_map_with_delimiters)
|
||||
gnc_account_imap_add_account_bayes (t_acc, tokens, t_expense_account1);
|
||||
auto account = gnc_account_imap_find_account_bayes (t_acc, tokens);
|
||||
EXPECT_EQ (account, t_expense_account1);
|
||||
g_list_free (tokens);
|
||||
}
|
||||
|
||||
TEST_F (ImapBayesTest, get_bayes_info)
|
||||
@ -383,5 +392,8 @@ TEST_F (ImapBayesTest, get_bayes_info)
|
||||
EXPECT_STREQ (info->head, (std::string {IMAP_FRAME_BAYES} + "/one/two/three/" + acct1_guid).c_str ());
|
||||
EXPECT_STREQ (info->match_string, "one/two/three");
|
||||
EXPECT_STREQ (info->count, "1");
|
||||
g_list_free_full (infos, (GDestroyNotify)gnc_account_imap_info_destroy);
|
||||
g_list_free (tokens);
|
||||
g_free (acct1_guid);
|
||||
}
|
||||
|
||||
|
@ -135,12 +135,14 @@ test_job (void)
|
||||
do_test (g_list_length (list) == 1, "correct joblist length");
|
||||
do_test (list->data == job, "verify job in list");
|
||||
gncJobSetActive (job, FALSE);
|
||||
g_list_free (list);
|
||||
list = gncCustomerGetJoblist (cust, FALSE);
|
||||
do_test (list == NULL, "no active jobs");
|
||||
list = gncCustomerGetJoblist (cust, TRUE);
|
||||
do_test (list != NULL, "all jobs");
|
||||
gncJobBeginEdit (job);
|
||||
gncJobDestroy (job);
|
||||
g_list_free (list);
|
||||
list = gncCustomerGetJoblist (cust, TRUE);
|
||||
do_test (list == NULL, "no more jobs");
|
||||
}
|
||||
@ -171,6 +173,8 @@ test_string_fcn (QofBook *book, const char *message,
|
||||
do_test (g_strcmp0 (get (job), str) == 0, message);
|
||||
g_free (str);
|
||||
gncJobSetActive (job, FALSE);
|
||||
gncJobBeginEdit (job);
|
||||
gncJobDestroy (job);
|
||||
count++;
|
||||
}
|
||||
|
||||
@ -196,6 +200,8 @@ test_numeric_fcn (QofBook *book, const char *message,
|
||||
// do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
|
||||
do_test (gnc_numeric_equal (get (job), num), message);
|
||||
gncJobSetActive (job, FALSE);
|
||||
gncJobBeginEdit (job);
|
||||
gncJobDestroy (job);
|
||||
count++;
|
||||
}
|
||||
|
||||
@ -223,6 +229,8 @@ test_bool_fcn (QofBook *book, const char *message,
|
||||
// do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
|
||||
do_test (get (job) == num, message);
|
||||
gncJobSetActive (job, FALSE);
|
||||
gncJobBeginEdit (job);
|
||||
gncJobDestroy (job);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -330,9 +330,10 @@ test_book_get_counter( Fixture *fixture, gconstpointer pData )
|
||||
counter = qof_book_get_counter( fixture->book, counter_name );
|
||||
g_assert_cmpint( counter, == , 0 );
|
||||
|
||||
qof_book_increment_and_format_counter( fixture->book, counter_name );
|
||||
char *r = qof_book_increment_and_format_counter( fixture->book, counter_name );
|
||||
counter = qof_book_get_counter( fixture->book, counter_name );
|
||||
g_assert_cmpint( counter, == , 1 );
|
||||
g_free (r);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -341,7 +342,7 @@ test_book_get_counter_format ( Fixture *fixture, gconstpointer pData )
|
||||
const char *counter_name = "Counter name";
|
||||
const char *err_no_book = "No book";
|
||||
const char *err_invalid_cnt = "Invalid counter name";
|
||||
const char *r;
|
||||
char *r;
|
||||
|
||||
/* need this as long as we have fatal warnings enabled */
|
||||
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )handle_faults, NULL );
|
||||
@ -367,10 +368,12 @@ test_book_get_counter_format ( Fixture *fixture, gconstpointer pData )
|
||||
g_test_message( "Testing counter format with existing counter" );
|
||||
r = qof_book_get_counter_format( fixture->book, counter_name );
|
||||
g_assert_cmpstr( r, == , "%.6" PRIi64);
|
||||
g_free (r);
|
||||
|
||||
g_test_message( "Testing counter format for default value" );
|
||||
r = qof_book_get_counter_format( fixture->book, counter_name );
|
||||
g_assert_cmpstr( r, == , "%.6" PRIi64);
|
||||
g_free (r);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -379,8 +382,7 @@ test_book_increment_and_format_counter ( Fixture *fixture, gconstpointer pData )
|
||||
const char *counter_name = "Counter name";
|
||||
const char *err_no_book = "No book";
|
||||
const char *err_invalid_cnt = "Invalid counter name";
|
||||
const char *format;
|
||||
char *r;
|
||||
char *r, *format, *format_str;
|
||||
gint64 counter;
|
||||
|
||||
/* need this as long as we have fatal warnings enabled */
|
||||
@ -411,18 +413,24 @@ test_book_increment_and_format_counter ( Fixture *fixture, gconstpointer pData )
|
||||
r = qof_book_increment_and_format_counter( fixture->book, counter_name );
|
||||
counter = qof_book_get_counter( fixture->book, counter_name );
|
||||
format = qof_book_get_counter_format( fixture->book, counter_name );
|
||||
format_str = g_strdup_printf (format, counter);
|
||||
g_assert_cmpint( counter, == , 1 );
|
||||
g_assert_true( qof_instance_is_dirty (QOF_INSTANCE (fixture->book)) );
|
||||
g_assert_cmpstr( r, == , g_strdup_printf( format, counter ));
|
||||
g_assert_cmpstr( r, == , format_str);
|
||||
g_free( r );
|
||||
g_free (format);
|
||||
g_free (format_str);
|
||||
|
||||
g_test_message( "Testing increment and format with existing counter" );
|
||||
r = qof_book_increment_and_format_counter( fixture->book, counter_name );
|
||||
counter = qof_book_get_counter( fixture->book, counter_name );
|
||||
format = qof_book_get_counter_format( fixture->book, counter_name );
|
||||
format_str = g_strdup_printf (format, counter);
|
||||
g_assert_cmpint( counter, == , 2 );
|
||||
g_assert_cmpstr( r, == , g_strdup_printf( format, counter ));
|
||||
g_assert_cmpstr( r, == , format_str);
|
||||
g_free( r );
|
||||
g_free (format);
|
||||
g_free (format_str);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -494,7 +502,7 @@ test_book_set_default_report ( Fixture *fixture, gconstpointer pData )
|
||||
const char *test_guid1 = "5123a759ceb9483abf2182d01c140eff";
|
||||
const char *test_guid2 = "5123a759ceb9483abf2182d01c140eee";
|
||||
const char *test_name = "My Invoice Report";
|
||||
const char *r;
|
||||
char *r;
|
||||
|
||||
/* need this as long as we have fatal warnings enabled */
|
||||
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )handle_faults, NULL );
|
||||
@ -524,15 +532,19 @@ test_book_set_default_report ( Fixture *fixture, gconstpointer pData )
|
||||
qof_book_set_default_invoice_report ( fixture->book, test_guid1, "" );
|
||||
r = qof_book_get_default_invoice_report_guid ( fixture->book );
|
||||
g_assert_cmpstr( r, == , test_guid1 );
|
||||
g_free (r);
|
||||
r = qof_book_get_default_invoice_report_name ( fixture->book );
|
||||
g_assert_cmpstr( r, == , "" );
|
||||
g_free (r);
|
||||
|
||||
g_test_message( "Testing setting default report with guid and name" );
|
||||
qof_book_set_default_invoice_report ( fixture->book, test_guid2, test_name );
|
||||
r = qof_book_get_default_invoice_report_guid ( fixture->book );
|
||||
g_assert_cmpstr( r, == , test_guid2 );
|
||||
g_free (r);
|
||||
r = qof_book_get_default_invoice_report_name ( fixture->book );
|
||||
g_assert_cmpstr( r, == , test_name );
|
||||
g_free (r);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -303,6 +303,7 @@ test_qof_object_book_begin( Fixture *fixture, gconstpointer pData )
|
||||
g_assert_cmpint( g_list_index( get_book_list(), (gconstpointer) book2 ), != , -1 );
|
||||
g_assert_cmpint( object_book_begin_struct.call_count, == , list_length );
|
||||
|
||||
qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
|
||||
qof_book_destroy( book2 );
|
||||
}
|
||||
|
||||
@ -333,6 +334,7 @@ test_qof_object_book_end( Fixture *fixture, gconstpointer pData )
|
||||
qof_book_destroy( book2 ); /* calls object_book_end */
|
||||
g_assert_cmpint( object_book_begin_struct.call_count, == , list_length );
|
||||
g_assert_cmpint( 0, == , g_list_length( get_book_list() ) );
|
||||
qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
|
||||
}
|
||||
|
||||
static struct
|
||||
@ -387,6 +389,7 @@ test_qof_object_is_dirty( Fixture *fixture, gconstpointer pData )
|
||||
g_assert_true( qof_object_is_dirty( book ) == TRUE );
|
||||
g_assert_cmpint( object_dirty_struct.call_count, == , 1 ); /* should break on first */
|
||||
|
||||
qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
|
||||
qof_book_destroy( book );
|
||||
}
|
||||
|
||||
@ -430,6 +433,7 @@ test_qof_object_mark_clean( Fixture *fixture, gconstpointer pData )
|
||||
qof_object_mark_clean( book );
|
||||
g_assert_cmpint( object_mark_clean_struct.call_count, == , list_length );
|
||||
|
||||
qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
|
||||
qof_book_destroy( book );
|
||||
}
|
||||
|
||||
@ -558,6 +562,7 @@ test_qof_object_foreach_type( Fixture *fixture, gconstpointer pData )
|
||||
foreach_type_cb_struct.call_count = 0;
|
||||
qof_object_foreach_type( mock_foreach_type_cb, ( gpointer ) &user_data );
|
||||
g_assert_cmpint( foreach_type_cb_struct.call_count, == , list_length );
|
||||
qof_object_foreach_type ((QofForeachTypeCB)g_free, NULL);
|
||||
}
|
||||
|
||||
static struct
|
||||
@ -680,7 +685,7 @@ test_qof_object_foreach_sorted( Fixture *fixture, gconstpointer pData )
|
||||
g_assert_cmpint( list_length, == , foreach_for_sorted_struct.call_count );
|
||||
|
||||
qof_book_destroy( book );
|
||||
g_list_free( foreach_for_sorted_struct.instances );
|
||||
g_list_free_full (foreach_for_sorted_struct.instances, g_object_unref);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user