From 88b0e265b6659c5460c67dd065be393acacc6c20 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 4 Nov 2010 17:31:18 +0000 Subject: [PATCH] Fix business-core tests so that all pass git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19754 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-core/test/test-customer.c | 16 +++++++++++++--- src/business/business-core/test/test-employee.c | 14 +++++++++++--- src/business/business-core/test/test-job.c | 12 ++++++++++-- src/business/business-core/test/test-vendor.c | 12 ++++++++++-- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/business/business-core/test/test-customer.c b/src/business/business-core/test/test-customer.c index 63b73b9bbf0..c7925a60c0d 100644 --- a/src/business/business-core/test/test-customer.c +++ b/src/business/business-core/test/test-customer.c @@ -161,9 +161,11 @@ test_string_fcn (QofBook *book, const char *message, do_test (!gncCustomerIsDirty (customer), "test if start dirty"); gncCustomerBeginEdit (customer); set (customer, str); + /* Customer record should be dirty */ do_test (gncCustomerIsDirty (customer), "test dirty later"); gncCustomerCommitEdit (customer); - do_test (gncCustomerIsDirty (customer), "test dirty after commit"); + /* Customer record should be not dirty */ + do_test (!gncCustomerIsDirty (customer), "test dirty after commit"); do_test (safe_strcmp (get (customer), str) == 0, message); gncCustomerSetActive (customer, FALSE); count++; @@ -180,9 +182,11 @@ test_numeric_fcn (QofBook *book, const char *message, do_test (!gncCustomerIsDirty (customer), "test if start dirty"); gncCustomerBeginEdit (customer); set (customer, num); + /* Customer record should be dirty */ do_test (gncCustomerIsDirty (customer), "test dirty later"); gncCustomerCommitEdit (customer); - do_test (gncCustomerIsDirty (customer), "test dirty after commit"); + /* Customer record should be not dirty */ + do_test (!gncCustomerIsDirty (customer), "test dirty after commit"); do_test (gnc_numeric_equal (get (customer), num), message); gncCustomerSetActive (customer, FALSE); count++; @@ -201,9 +205,11 @@ test_bool_fcn (QofBook *book, const char *message, set (customer, FALSE); set (customer, TRUE); set (customer, num); + /* Customer record should be dirty */ do_test (gncCustomerIsDirty (customer), "test dirty later"); gncCustomerCommitEdit (customer); - do_test (gncCustomerIsDirty (customer), "test dirty after commit"); + /* Customer record should be not dirty */ + do_test (!gncCustomerIsDirty (customer), "test dirty after commit"); do_test (get (customer) == num, message); gncCustomerSetActive (customer, FALSE); count++; @@ -215,9 +221,13 @@ main (int argc, char **argv) qof_init(); qof_load_backend_library ("../../../backend/xml/.libs/", GNC_LIB_NAME); do_test (cashobjects_register(), "Cannot register cash objects"); + /* These three registrations are done during cashobjects_register, + so trying to register them again naturally fails. */ +#if 0 do_test (gncInvoiceRegister(), "Cannot register GncInvoice"); do_test (gncJobRegister (), "Cannot register GncJob"); do_test (gncCustomerRegister(), "Cannot register GncCustomer"); +#endif test_customer(); print_test_results(); qof_close (); diff --git a/src/business/business-core/test/test-employee.c b/src/business/business-core/test/test-employee.c index 8141b6286ac..db944237476 100644 --- a/src/business/business-core/test/test-employee.c +++ b/src/business/business-core/test/test-employee.c @@ -151,9 +151,11 @@ test_string_fcn (QofBook *book, const char *message, do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, str); + /* Employee record should be dirty */ do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); - do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); + /* Employee record should be not dirty */ + do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (safe_strcmp (get (employee), str) == 0, message); gncEmployeeSetActive (employee, FALSE); count++; @@ -170,9 +172,11 @@ test_numeric_fcn (QofBook *book, const char *message, do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, num); + /* Employee record should be dirty */ do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); - do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); + /* Employee record should be not dirty */ + do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (gnc_numeric_equal (get (employee), num), message); gncEmployeeSetActive (employee, FALSE); count++; @@ -191,9 +195,11 @@ test_bool_fcn (QofBook *book, const char *message, set (employee, FALSE); set (employee, TRUE); set (employee, num); + /* Employee record should be dirty */ do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); - do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); + /* Employee record should be not dirty */ + do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; @@ -211,8 +217,10 @@ test_gint_fcn (QofBook *book, const char *message, do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, num); + /* Employee record should be dirty */ do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); + /* Employee record should be not dirty */ do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); diff --git a/src/business/business-core/test/test-job.c b/src/business/business-core/test/test-job.c index 675585d9095..4dbbb07e5ad 100644 --- a/src/business/business-core/test/test-job.c +++ b/src/business/business-core/test/test-job.c @@ -171,9 +171,11 @@ test_string_fcn (QofBook *book, const char *message, do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test if start dirty"); gncJobBeginEdit (job); set (job, str); + /* Job record should be dirty */ do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty later"); gncJobCommitEdit (job); - do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit"); + /* Job record should be not dirty */ + do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit"); do_test (safe_strcmp (get (job), str) == 0, message); gncJobSetActive (job, FALSE); count++; @@ -191,8 +193,10 @@ test_numeric_fcn (QofBook *book, const char *message, do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test if start dirty"); gncJobBeginEdit (job); set (job, num); + /* Job record should be dirty */ do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty later"); gncJobCommitEdit (job); + /* Job record should be not dirty */ 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); @@ -213,9 +217,11 @@ test_bool_fcn (QofBook *book, const char *message, set (job, FALSE); set (job, TRUE); set (job, num); + /* Job record should be dirty */ do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty later"); gncJobCommitEdit (job); - do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit"); + /* Job record should be not dirty */ + do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit"); do_test (get (job) == num, message); gncJobSetActive (job, FALSE); count++; @@ -233,8 +239,10 @@ test_gint_fcn (QofBook *book, const char *message, do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test if start dirty"); gncJobBeginEdit (job); set (job, num); + /* Job record should be dirty */ do_test (qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty later"); gncJobCommitEdit (job); + /* Job record should be not dirty */ do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit"); do_test (get (job) == num, message); gncJobSetActive (job, FALSE); diff --git a/src/business/business-core/test/test-vendor.c b/src/business/business-core/test/test-vendor.c index 8c40f0a29c9..a0923a8cf80 100644 --- a/src/business/business-core/test/test-vendor.c +++ b/src/business/business-core/test/test-vendor.c @@ -150,9 +150,11 @@ test_string_fcn (QofBook *book, const char *message, do_test (!gncVendorIsDirty (vendor), "test if start dirty"); gncVendorBeginEdit (vendor); set (vendor, str); + /* Vendor record should be dirty */ do_test (gncVendorIsDirty (vendor), "test dirty later"); gncVendorCommitEdit (vendor); - do_test (gncVendorIsDirty (vendor), "test dirty after commit"); + /* Vendor record should be not dirty */ + do_test (!gncVendorIsDirty (vendor), "test dirty after commit"); do_test (safe_strcmp (get (vendor), str) == 0, message); gncVendorSetActive (vendor, FALSE); count++; @@ -170,8 +172,10 @@ test_numeric_fcn (QofBook *book, const char *message, do_test (!gncVendorIsDirty (vendor), "test if start dirty"); gncVendoryBeginEdit (vendor); set (vendor, num); + /* Vendor record should be dirty */ do_test (gncVendorIsDirty (vendor), "test dirty later"); gncVendorCommitEdit (vendor); + /* Vendor record should be not dirty */ do_test (!gncVendorIsDirty (vendor), "test dirty after commit"); do_test (gnc_numeric_equal (get (vendor), num), message); gncVendorSetActive (vendor, FALSE); @@ -192,9 +196,11 @@ test_bool_fcn (QofBook *book, const char *message, set (vendor, FALSE); set (vendor, TRUE); set (vendor, num); + /* Vendor record should be dirty */ do_test (gncVendorIsDirty (vendor), "test dirty later"); gncVendorCommitEdit (vendor); - do_test (gncVendorIsDirty (vendor), "test dirty after commit"); + /* Vendor record should be not dirty */ + do_test (!gncVendorIsDirty (vendor), "test dirty after commit"); do_test (get (vendor) == num, message); gncVendorSetActive (vendor, FALSE); count++; @@ -212,8 +218,10 @@ test_gint_fcn (QofBook *book, const char *message, do_test (!gncVendorIsDirty (vendor), "test if start dirty"); gncVendorBeginEdit (vendor); set (vendor, num); + /* Vendor record should be dirty */ do_test (gncVendorIsDirty (vendor), "test dirty later"); gncVendorCommitEdit (vendor); + /* Vendor record should be not dirty */ do_test (!gncVendorIsDirty (vendor), "test dirty after commit"); do_test (get (vendor) == num, message); gncVendorSetActive (vendor, FALSE);