r21605 - gnucash/trunk - Dissolve the business-core module, by integrating its remaining bits in
Geert Janssens
gjanssens at code.gnucash.org
Mon Nov 21 05:40:17 EST 2011
Author: gjanssens
Date: 2011-11-21 05:40:17 -0500 (Mon, 21 Nov 2011)
New Revision: 21605
Trac: http://svn.gnucash.org/trac/changeset/21605
Added:
gnucash/trunk/src/engine/business-core.scm
gnucash/trunk/src/engine/test/test-address.c
gnucash/trunk/src/engine/test/test-business.c
gnucash/trunk/src/engine/test/test-customer.c
gnucash/trunk/src/engine/test/test-employee.c
gnucash/trunk/src/engine/test/test-job.c
gnucash/trunk/src/engine/test/test-vendor.c
Removed:
gnucash/trunk/src/business/business-core/Makefile.am
gnucash/trunk/src/business/business-core/business-core.scm
gnucash/trunk/src/business/business-core/gncmod-business-core.c
gnucash/trunk/src/business/business-core/test/Makefile.am
gnucash/trunk/src/business/business-core/test/README
gnucash/trunk/src/business/business-core/test/test-address.c
gnucash/trunk/src/business/business-core/test/test-business.c
gnucash/trunk/src/business/business-core/test/test-customer.c
gnucash/trunk/src/business/business-core/test/test-employee.c
gnucash/trunk/src/business/business-core/test/test-job.c
gnucash/trunk/src/business/business-core/test/test-load-module.c
gnucash/trunk/src/business/business-core/test/test-vendor.c
Modified:
gnucash/trunk/configure.ac
gnucash/trunk/src/business/Makefile.am
gnucash/trunk/src/business/business-gnome/Makefile.am
gnucash/trunk/src/business/business-gnome/business-gnome.scm
gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c
gnucash/trunk/src/business/business-ledger/Makefile.am
gnucash/trunk/src/business/business-utils/business-utils.scm
gnucash/trunk/src/business/business-utils/gncmod-business-utils.c
gnucash/trunk/src/business/dialog-tax-table/Makefile.am
gnucash/trunk/src/business/dialog-tax-table/gncmod-dialog-tax-table.c
gnucash/trunk/src/engine/Makefile.am
gnucash/trunk/src/engine/business-core.i
gnucash/trunk/src/engine/engine.i
gnucash/trunk/src/engine/gncmod-engine.c
gnucash/trunk/src/engine/test/Makefile.am
gnucash/trunk/src/engine/test/README
gnucash/trunk/src/optional/python-bindings/Makefile.am
gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c
gnucash/trunk/src/report/business-reports/aging.scm
Log:
Dissolve the business-core module, by integrating its remaining bits in
the engine, where the rest already was moved before.
Modified: gnucash/trunk/configure.ac
===================================================================
--- gnucash/trunk/configure.ac 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/configure.ac 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1336,8 +1336,6 @@
src/tax/us/test/Makefile
src/test-core/Makefile
src/business/Makefile
- src/business/business-core/Makefile
- src/business/business-core/test/Makefile
src/business/business-utils/Makefile
src/business/dialog-tax-table/Makefile
src/business/business-gnome/Makefile
Modified: gnucash/trunk/src/business/Makefile.am
===================================================================
--- gnucash/trunk/src/business/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,5 +1,4 @@
SUBDIRS = \
- business-core \
business-utils \
dialog-tax-table \
business-ledger \
Deleted: gnucash/trunk/src/business/business-core/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-core/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,62 +0,0 @@
-SUBDIRS = . test
-
-pkglib_LTLIBRARIES = libgncmod-business-core.la
-
-AM_CPPFLAGS = \
- -I${top_srcdir}/src \
- -I${top_builddir}/src \
- -I${top_srcdir}/src/engine \
- -I${top_srcdir}/src/gnc-module \
- -I${top_srcdir}/src/libqof/qof \
- ${GUILE_INCS} \
- ${GLIB_CFLAGS}
-
-libgncmod_business_core_la_SOURCES = \
- gncmod-business-core.c
-
-noinst_HEADERS =
-
-libgncmod_business_core_la_LDFLAGS = -avoid-version
-
-libgncmod_business_core_la_LIBADD = \
- ${top_builddir}/src/gnc-module/libgnc-module.la \
- ${top_builddir}/src/engine/libgncmod-engine.la \
- ${top_builddir}/src/libqof/qof/libgnc-qof.la \
- ${GUILE_LIBS} \
- ${GLIB_LIBS} \
- ${EFENCE_LIBS}
-
-# business-core-helpers.c
-
-gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
-gncmod_DATA = business-core.scm
-
-EXTRA_DIST = ${gncmod_DATA}
-
-if GNUCASH_SEPARATE_BUILDDIR
-#For executing test cases
-SCM_FILE_LINKS = ${gncmod_DATA}
-endif
-
-.scm-links:
- $(RM) -rf gnucash
- mkdir -p gnucash
-if GNUCASH_SEPARATE_BUILDDIR
- for X in ${SCM_FILE_LINKS} ; do \
- $(LN_S) -f ${srcdir}/$$X . ; \
- done
-endif
- ( cd gnucash; for A in $(gncmod_DATA) ; do $(LN_S) -f ../$$A . ; done )
-if ! OS_WIN32
-# Windows knows no "ln -s" but uses "cp": must copy every time (see bug #566567).
- touch .scm-links
-endif
-
-noinst_DATA = .scm-links
-clean-local:
- rm -rf gnucash
-
-CLEANFILES = gnucash .scm-links ${SCM_FILE_LINKS}
-MAINTAINERCLEANFILES =
-
-INCLUDES = -DG_LOG_DOMAIN=\"gnc.business.core\"
Deleted: gnucash/trunk/src/business/business-core/business-core.scm
===================================================================
--- gnucash/trunk/src/business/business-core/business-core.scm 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/business-core.scm 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,133 +0,0 @@
-(define-module (gnucash business-core))
-(use-modules (sw_business_core))
-(use-modules (gnucash gnc-module))
-(gnc:module-load "gnucash/engine" 0)
-
-(define (gnc:owner-get-address owner)
- (let ((type (gncOwnerGetType owner)))
- (cond
- ((eqv? type GNC-OWNER-CUSTOMER)
- (let ((c (gncOwnerGetCustomer owner)))
- (gncCustomerGetAddr c)))
- ((eqv? type GNC-OWNER-VENDOR)
- (let ((v (gncOwnerGetVendor owner)))
- (gncVendorGetAddr v)))
- ((eqv? type GNC-OWNER-EMPLOYEE)
- (let ((e (gncOwnerGetEmployee owner)))
- (gncEmployeeGetAddr e)))
- ((eqv? type GNC-OWNER-JOB)
- (gnc:owner-get-address (gncJobGetOwner
- (gncOwnerGetJob owner))))
- (else '()))))
-
-;
-; The -dep functions return combined strings of the appropriate
-; content. When multiple "lines" are included, separate them
-; by newlines.
-;
-; e.g.: return a string which is basically:
-; name \n Attn: contact \n addr1 \n addr2 \n addr3 \n addr4
-;
-; But only include the strings that really exist.
-;
-
-(define (gnc:owner-get-name-dep owner)
- (define (just-name name)
- (if name name ""))
-
- (let ((type (gncOwnerGetType owner)))
- (cond
- ((eqv? type GNC-OWNER-JOB)
- (gnc:owner-get-name-dep (gncJobGetOwner
- (gncOwnerGetJob owner))))
- (else (just-name (gncOwnerGetName owner))))))
-
-(define (gnc:owner-get-address-dep owner)
- (define (add-if-exists lst new)
- (if (and new (> (string-length new) 0))
- (cons new lst)
- lst))
- (define (build-string lst)
- (cond
- ((null? lst) "")
- ((null? (cdr lst)) (car lst))
- (else (string-append (build-string (cdr lst)) "\n" (car lst)))))
- (let ((lst '())
- (addr (gnc:owner-get-address owner)))
-; Added gncAddressGetName <mikee at saxicola.co.uk>
- (set! lst (add-if-exists lst (gncAddressGetName addr)))
- (set! lst (add-if-exists lst (gncAddressGetAddr1 addr)))
- (set! lst (add-if-exists lst (gncAddressGetAddr2 addr)))
- (set! lst (add-if-exists lst (gncAddressGetAddr3 addr)))
- (set! lst (add-if-exists lst (gncAddressGetAddr4 addr)))
- (build-string lst)))
-
-(define (gnc:owner-get-name-and-address-dep owner)
- (let ((name (gnc:owner-get-name-dep owner))
- (addr (gnc:owner-get-address-dep owner)))
- (if (> (string-length name) 0)
- (string-append name "\n" addr)
- addr)))
-
-(define (gnc:owner-get-owner-id owner)
- (let ((type (gncOwnerGetType owner)))
- (cond
- ((eqv? type GNC-OWNER-CUSTOMER)
- (let ((c (gncOwnerGetCustomer owner)))
- (gncCustomerGetID c)))
- ((eqv? type GNC-OWNER-VENDOR)
- (let ((v (gncOwnerGetVendor owner)))
- (gncVendorGetID v)))
- ((eqv? type GNC-OWNER-EMPLOYEE)
- (let ((e (gncOwnerGetEmployee owner)))
- (gncEmployeeGetID e)))
- ((eqv? type GNC-OWNER-JOB)
- (gnc:owner-get-owner-id (gncJobGetOwner (gncOwnerGetJob owner))))
- (else ""))))
-
-(define (gnc:entry-type-percent-p type-val)
- (let ((type type-val))
- (equal? type GNC-AMT-TYPE-PERCENT)))
-
-(define (gnc:owner-from-split split result-owner)
- (let* ((trans (xaccSplitGetParent split))
- (invoice (gncInvoiceGetInvoiceFromTxn trans))
- (temp-owner (gncOwnerNew))
- (owner '()))
-
- (if (not (null? invoice))
- (set! owner (gncInvoiceGetOwner invoice))
- (let ((split-list (xaccTransGetSplitList trans)))
- (define (check-splits splits)
- (if (and splits (not (null? splits)))
- (let* ((split (car splits))
- (lot (xaccSplitGetLot split)))
- (if (not (null? lot))
- (let* ((invoice (gncInvoiceGetInvoiceFromLot lot))
- (owner? (gncOwnerGetOwnerFromLot
- lot temp-owner)))
- (if (not (null? invoice))
- (set! owner (gncInvoiceGetOwner invoice))
- (if owner?
- (set! owner temp-owner)
- (check-splits (cdr splits)))))
- (check-splits (cdr splits))))))
- (check-splits split-list)))
-
- (if (not (null? owner))
- (begin
- (gncOwnerCopy (gncOwnerGetEndOwner owner) result-owner)
- (gncOwnerFree temp-owner)
- result-owner)
- (begin
- (gncOwnerFree temp-owner)
- '()))))
-
-
-(export gnc:owner-get-address)
-(export gnc:owner-get-name-dep)
-(export gnc:owner-get-address-dep)
-(export gnc:owner-get-name-and-address-dep)
-(export gnc:owner-get-owner-id)
-(export gnc:entry-type-percent-p)
-(export gnc:owner-from-split)
Deleted: gnucash/trunk/src/business/business-core/gncmod-business-core.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncmod-business-core.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/gncmod-business-core.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,84 +0,0 @@
-/*********************************************************************
- * businessmod-core.c
- * module definition/initialization for the core Business module
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- *
- * 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 <gmodule.h>
-#include <libguile.h>
-
-#include "gnc-module.h"
-#include "gnc-module-api.h"
-#include "gncBusiness.h"
-
-GNC_MODULE_API_DECL(libgncmod_business_core)
-
-extern SCM scm_init_sw_business_core_module (void);
-
-/* version of the gnc module system interface we require */
-int libgncmod_business_core_gnc_module_system_interface = 0;
-
-/* module versioning uses libtool semantics. */
-int libgncmod_business_core_gnc_module_current = 0;
-int libgncmod_business_core_gnc_module_revision = 0;
-int libgncmod_business_core_gnc_module_age = 0;
-
-
-char *
-libgncmod_business_core_gnc_module_path(void)
-{
- return g_strdup("gnucash/business-core");
-}
-
-char *
-libgncmod_business_core_gnc_module_description(void)
-{
- return g_strdup("The GnuCash business core");
-}
-
-int
-libgncmod_business_core_gnc_module_init(int refcount)
-{
- /* load the engine (we depend on it) */
- if (!gnc_module_load("gnucash/engine", 0))
- {
- return FALSE;
- }
-
- if (refcount == 0)
- {
- /* Object initialization already finished in the engine. */
- }
-
- scm_init_sw_business_core_module();
- scm_c_eval_string("(use-modules (sw_business_core))");
- scm_c_eval_string("(use-modules (gnucash business-core))");
-
- return TRUE;
-}
-
-int
-libgncmod_business_core_gnc_module_end(int refcount)
-{
- return TRUE;
-}
Deleted: gnucash/trunk/src/business/business-core/test/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-core/test/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,55 +0,0 @@
-
-AM_CPPFLAGS = \
- -I${top_srcdir}/src \
- -I${top_srcdir}/src/gnc-module \
- -I${top_srcdir}/src/test-core \
- -I${top_srcdir}/src/engine \
- -I${top_srcdir}/src/business/business-core \
- -I${top_srcdir}/src/libqof/qof \
- -I${top_srcdir}/src/backend/xml \
- ${GUILE_INCS} \
- ${GLIB_CFLAGS}
-
-LDADD = \
- ${top_builddir}/src/libqof/qof/libgnc-qof.la \
- ${top_builddir}/src/gnc-module/libgnc-module.la \
- ${top_builddir}/src/test-core/libtest-core.la \
- ${top_builddir}/src/engine/libgncmod-engine.la \
- ../libgncmod-business-core.la \
- ${GLIB_LIBS}
-
-TESTS = \
- test-load-module \
- test-business \
- test-address \
- test-customer \
- test-employee \
- test-job \
- test-vendor
-
-GNC_TEST_DEPS = \
- --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/business/business-core \
- --guile-load-dir ${top_builddir}/src/gnc-module \
- --guile-load-dir ${top_builddir}/src/engine \
- --guile-load-dir ${top_builddir}/src/business/business-core \
- --library-dir ${top_builddir}/src/libqof/qof \
- --library-dir ${top_builddir}/src/core-utils \
- --library-dir ${top_builddir}/src/gnc-module \
- --library-dir ${top_builddir}/src/engine \
- --library-dir ${top_builddir}/src/business/business-core \
- --library-dir ${top_builddir}/src/backend/xml
-
-TESTS_ENVIRONMENT = \
- $(shell ${top_srcdir}/src/gnc-test-env --no-exports ${GNC_TEST_DEPS})
-
-check_PROGRAMS = \
- test-load-module \
- test-business \
- test-address \
- test-customer \
- test-employee \
- test-job \
- test-vendor
-
-EXTRA_DIST =
Deleted: gnucash/trunk/src/business/business-core/test/README
===================================================================
--- gnucash/trunk/src/business/business-core/test/README 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/README 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,26 +0,0 @@
-
-
-This directory contains unit test cases for the core business objects.
-
-
-Notes on test of dirty/clean flag:
----------------------------------
-Test cases will fail the test of the 'dirty' flag if a backend
-is not set up. That's because the 'dirty' flag is supposed to be
-cleared by the backend only.
-An object cannot be marked 'clean' unless it has actually
-been saved to a file or sql db. (Or, in the case of the file
-backend, the 'dirtiness' of the data has been duly noted, and
-will be taken care of for the next file save.
-Until its saved, it lives in perpetual dirtiness. Thus, the
-test cases need to specify a backend, then do the commit,
-then test the dirty flag.
-
-Actually, the use of the dirty flag in gnucash is, at this time,
-mildly ambiguous, and its semantics are not clearly defined.
-
-
-TODO
-----
-Make tests better
-
Deleted: gnucash/trunk/src/business/business-core/test/test-address.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-address.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-address.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,99 +0,0 @@
-/*********************************************************************
- * test-address.c
- * object definition/initialization for Address
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
- *
- * 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 <glib.h>
-#include "cashobjects.h"
-#include "gncAddressP.h"
-#include "test-stuff.h"
-
-static void
-test_string_fcn (GncAddress *address, const char *message,
- void (*set) (GncAddress *, const char *str),
- const char * (*get)(const GncAddress *));
-
-static void
-test_address (void)
-{
- QofInstance *ent;
- GncAddress *address;
- QofBook *book = qof_book_new ();
-
- ent = g_object_new(QOF_TYPE_INSTANCE, "guid", guid_null(), NULL);
- ent->e_type = "asdf";
-
- /* Test creation/destruction */
- {
- do_test (gncAddressCreate (NULL, NULL) == NULL, "address create NULL");
-
- address = gncAddressCreate (book, ent);
- do_test (address != NULL, "address create");
-
- gncAddressBeginEdit (address);
- gncAddressDestroy (address);
- success ("create/destroy");
- }
-
- /* Test setting routines */
- {
- address = gncAddressCreate (book, ent);
- test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName);
- test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1);
- test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2);
- test_string_fcn (address, "Addr3", gncAddressSetAddr3, gncAddressGetAddr3);
- test_string_fcn (address, "Addr4", gncAddressSetAddr4, gncAddressGetAddr4);
- test_string_fcn (address, "Phone", gncAddressSetPhone, gncAddressGetPhone);
- test_string_fcn (address, "Fax", gncAddressSetFax, gncAddressGetFax);
- test_string_fcn (address, "Email", gncAddressSetEmail, gncAddressGetEmail);
- }
-}
-
-static void
-test_string_fcn (GncAddress *address, const char *message,
- void (*set) (GncAddress *, const char *str),
- const char * (*get)(const GncAddress *))
-{
- char const *str = get_random_string ();
-
- do_test (!gncAddressIsDirty (address), "test if start dirty");
- set (address, str);
- do_test (gncAddressIsDirty (address), "test dirty later");
- do_test (safe_strcmp (get (address), str) == 0, message);
- gncAddressClearDirty (address);
-}
-
-int
-main (int argc, char **argv)
-{
- qof_init();
- if (cashobjects_register())
- {
- test_address();
- print_test_results();
- }
- qof_close();
- return 0;
-}
Deleted: gnucash/trunk/src/business/business-core/test/test-business.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-business.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-business.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,138 +0,0 @@
-/*********************************************************************
- * test-business.c
- * Test the business code.
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- *
- * 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 <glib.h>
-#include <libguile.h>
-
-#include "qof.h"
-#include "gnc-module.h"
-
-#include "gncBusiness.h"
-#include "test-stuff.h"
-
-#define TEST_MODULE_NAME "business-test"
-#define TEST_MODULE_DESC "Test Business"
-
-#if 0
-static GList * get_list (QofBook *, gboolean show_all);
-static const char * printable (gpointer obj);
-static void test_printable (const char *name, gpointer obj);
-static void test_get_list (QofBook *, const char *);
-
-static GncBusinessObject bus_obj =
-{
- GNC_BUSINESS_VERSION,
- TEST_MODULE_NAME,
- TEST_MODULE_DESC,
- NULL, /* create */
- NULL, /* destroy */
- get_list,
- printable,
-};
-
-static void test_business (void)
-{
- /* Test the global registration and lookup functions */
- {
- do_test (!gncBusinessRegister (NULL), "register NULL");
- do_test (gncBusinessRegister (&bus_obj), "register test object");
- do_test (!gncBusinessRegister (&bus_obj), "register test object again");
- do_test (gncBusinessLookup (TEST_MODULE_NAME) == &bus_obj,
- "lookup our installed object");
- do_test (gncBusinessLookup ("snm98sn snml say dyikh9y9ha") == NULL,
- "lookup non-existant business object");
-
- do_test (!safe_strcmp (gncBusinessGetTypeLabel (TEST_MODULE_NAME),
- _(TEST_MODULE_DESC)),
- "test description return");
- }
-
- test_get_list ((QofBook*)1, TEST_MODULE_NAME);
- test_printable (TEST_MODULE_NAME, (gpointer)1);
-}
-
-static GList *
-get_list (QofBook *book, gboolean show_all)
-{
- do_test (book != NULL, "get_list: NULL business");
- success ("called get_list callback");
- return ((GList *)1);
-}
-
-static const char *
-printable (gpointer obj)
-{
- do_test (obj != NULL, "printable: object is NULL");
- success ("called printable callback");
- return ((const char *)obj);
-}
-
-static void
-test_get_list (QofBook *book, const char *name)
-{
- GList *res;
-
- do_test (gncBusinessGetList (NULL, NULL, FALSE) == NULL,
- "business: GetList: NULL, NULL, FALSE");
- do_test (gncBusinessGetList (NULL, name, FALSE) == NULL,
- "business: GetList: NULL, mod_name, FALSE");
- do_test (gncBusinessGetList (book, NULL, FALSE) == NULL,
- "business: GetList: book, NULL, FALSE");
- res = gncBusinessGetList (book, name, FALSE);
- do_test (res != NULL, "business: GetList: book, mod_name, FALSE");
-}
-
-static void
-test_printable (const char *name, gpointer obj)
-{
- const char *res;
-
- do_test (gncBusinessPrintable (NULL, NULL) == NULL,
- "business: Printable: NULL, NULL");
- do_test (gncBusinessPrintable (NULL, obj) == NULL,
- "business: Printable: NULL, object");
- do_test (gncBusinessPrintable (name, NULL) == NULL,
- "business: Printable: mod_name, NULL");
- res = gncBusinessPrintable (name, obj);
- do_test (res != NULL, "business: Printable: mod_name, object");
-}
-
-static void
-main_helper (void *closure, int argc, char **argv)
-{
- gnc_module_load("gnucash/business-core", 0);
- test_business();
- print_test_results();
- exit(get_rv());
-}
-#endif
-
-int
-main (int argc, char **argv)
-{
- // scm_boot_guile (argc, argv, main_helper, NULL);
- return 0;
-}
Deleted: gnucash/trunk/src/business/business-core/test/test-customer.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-customer.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-customer.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,235 +0,0 @@
-/*********************************************************************
- * test-customer.c
- * Test the customer object (without Guile/Scheme)
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
- *
- * 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 <glib.h>
-#include "qof.h"
-#include "cashobjects.h"
-#include "gncCustomerP.h"
-#include "gncInvoiceP.h"
-#include "gncJobP.h"
-#include "test-stuff.h"
-
-#include "gnc-backend-xml.h"
-
-#define FILE_NAME "xml:///tmp/testbook.gnucash"
-#define GNC_LIB_NAME "gncmod-backend-xml"
-
-static int count = 0;
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncCustomer *, const char *str),
- const char * (*get)(const GncCustomer *));
-
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncCustomer *, gnc_numeric),
- gnc_numeric (*get)(const GncCustomer *));
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncCustomer *, gboolean),
- gboolean (*get) (const GncCustomer *));
-
-static void
-test_customer (void)
-{
- QofBackend *be;
- QofSession *session;
- QofBook *book;
- GncCustomer *customer;
-
- session = qof_session_new();
- be = NULL;
- qof_session_begin(session, FILE_NAME, FALSE, FALSE, FALSE);
- book = qof_session_get_book(session);
- be = qof_book_get_backend(book);
-
- /* The book *must* have a backend to pass the test of the 'dirty' flag
- so use a session to use the default XML. However, until the SQL backend can be used,
- entities remain dirty until the session is saved or closed. */
- do_test (be != NULL, "xml backend could not be set");
-
- /* Test creation/destruction */
- {
- do_test (gncCustomerCreate (NULL) == NULL, "customer create NULL");
- customer = gncCustomerCreate (book);
- do_test (customer != NULL, "customer create");
- do_test (gncCustomerGetBook (customer) == book, "getbook");
-
- gncCustomerBeginEdit (customer);
- gncCustomerDestroy (customer);
- success ("create/destroy");
- }
-
- /* Test setting/getting routines; does the active flag get set right? */
- {
- GncGUID guid;
-
- test_string_fcn (book, "Id", gncCustomerSetID, gncCustomerGetID);
- test_string_fcn (book, "Name", gncCustomerSetName, gncCustomerGetName);
- test_string_fcn (book, "Notes", gncCustomerSetNotes, gncCustomerGetNotes);
-
- //test_string_fcn (book, "Terms", gncCustomerSetTerms, gncCustomerGetTerms);
-
- test_numeric_fcn (book, "Discount", gncCustomerSetDiscount, gncCustomerGetDiscount);
- test_numeric_fcn (book, "Credit", gncCustomerSetCredit, gncCustomerGetCredit);
-
- test_bool_fcn (book, "Active", gncCustomerSetActive, gncCustomerGetActive);
-
- do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
- do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
-
- guid_new (&guid);
- customer = gncCustomerCreate (book);
- count++;
- gncCustomerSetGUID (customer, &guid);
- do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare");
- }
- {
- GList *list;
-
- list = gncBusinessGetList (book, GNC_ID_CUSTOMER, TRUE);
- do_test (list != NULL, "getList all");
- do_test (g_list_length (list) == count, "correct length: all");
- g_list_free (list);
-
- list = gncBusinessGetList (book, GNC_ID_CUSTOMER, FALSE);
- do_test (list != NULL, "getList active");
- do_test (g_list_length (list) == 1, "correct length: active");
- g_list_free (list);
- }
- {
- const char *str = get_random_string();
- const char *res;
-
- res = NULL;
- gncCustomerBeginEdit(customer);
- gncCustomerSetName (customer, str);
- gncCustomerCommitEdit(customer);
- res = qof_object_printable (GNC_ID_CUSTOMER, customer);
- do_test (res != NULL, "Printable NULL?");
- do_test (safe_strcmp (str, res) == 0, "Printable equals");
- }
-
- do_test (gncCustomerGetJoblist (customer, TRUE) == NULL, "joblist empty");
-
- /* Test the Entity Table */
- {
- const GncGUID *guid;
-
- guid = gncCustomerGetGUID (customer);
- do_test (gncCustomerLookup (book, guid) == customer, "Entity Table");
- }
-
- /* Note: JobList is tested from the Job tests */
- qof_session_end(session);
-}
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncCustomer *, const char *str),
- const char * (*get)(const GncCustomer *))
-{
- GncCustomer *customer = gncCustomerCreate (book);
- char const *str = get_random_string ();
-
- 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);
- /* 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++;
-}
-
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncCustomer *, gnc_numeric),
- gnc_numeric (*get)(const GncCustomer *))
-{
- GncCustomer *customer = gncCustomerCreate (book);
- gnc_numeric num = gnc_numeric_create (17, 1);
-
- 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);
- /* 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++;
-}
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncCustomer *, gboolean),
- gboolean (*get) (const GncCustomer *))
-{
- GncCustomer *customer = gncCustomerCreate (book);
- gboolean num = get_random_boolean ();
-
- do_test (!gncCustomerIsDirty (customer), "test if start dirty");
- gncCustomerBeginEdit (customer);
- set (customer, FALSE);
- set (customer, TRUE);
- set (customer, num);
- /* Customer record should be dirty */
- do_test (gncCustomerIsDirty (customer), "test dirty later");
- gncCustomerCommitEdit (customer);
- /* Customer record should be not dirty */
- do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
- do_test (get (customer) == num, message);
- gncCustomerSetActive (customer, FALSE);
- count++;
-}
-
-int
-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 ();
- return 0;
-}
Deleted: gnucash/trunk/src/business/business-core/test/test-employee.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-employee.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-employee.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,244 +0,0 @@
-/*********************************************************************
- * test-employee.c
- * Test the employee object (without Guile).
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
- *
- * 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 <glib.h>
-#include "qof.h"
-#include "gncEmployeeP.h"
-#include "gncCustomerP.h"
-#include "gncJobP.h"
-#include "gncInvoiceP.h"
-#include "test-stuff.h"
-
-#include "gnc-backend-xml.h"
-
-#define FILE_NAME "xml:///tmp/testbook.gnucash"
-#define GNC_LIB_NAME "gncmod-backend-xml"
-
-static int count = 0;
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, const char *str),
- const char * (*get)(const GncEmployee *));
-
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, gnc_numeric),
- gnc_numeric (*get)(const GncEmployee *));
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, gboolean),
- gboolean (*get) (const GncEmployee *));
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, gint),
- gint (*get) (GncEmployee *));
-#endif
-
-static void
-test_employee (void)
-{
- QofBackend *be;
- QofBook *book;
- QofSession *session;
- GncEmployee *employee;
-
- session = qof_session_new();
- qof_session_begin(session, FILE_NAME, FALSE, FALSE, FALSE);
- book = qof_session_get_book(session);
- be = qof_book_get_backend (book);
-
- /* The book *must* have a backend to pass the test of the 'dirty' flag */
- /* See the README file for details */
- do_test (be != NULL, "xml backend could not be set");
-
- /* Test creation/destruction */
- {
- do_test (gncEmployeeCreate (NULL) == NULL, "employee create NULL");
- employee = gncEmployeeCreate (book);
- do_test (employee != NULL, "employee create");
- do_test (qof_instance_get_book(QOF_INSTANCE(employee)) == book,
- "getbook");
-
- gncEmployeeBeginEdit (employee);
- gncEmployeeDestroy (employee);
- success ("create/destroy");
- }
-
- /* Test setting/getting routines; does the active flag get set right? */
- {
- GncGUID guid;
-
- test_string_fcn (book, "Id", gncEmployeeSetID, gncEmployeeGetID);
- test_string_fcn (book, "Username", gncEmployeeSetUsername, gncEmployeeGetUsername);
- test_string_fcn (book, "Language", gncEmployeeSetLanguage, gncEmployeeGetLanguage);
- test_string_fcn (book, "Acl", gncEmployeeSetAcl, gncEmployeeGetAcl);
-
- test_numeric_fcn (book, "Workday", gncEmployeeSetWorkday, gncEmployeeGetWorkday);
- test_numeric_fcn (book, "Rate", gncEmployeeSetRate, gncEmployeeGetRate);
-
- test_bool_fcn (book, "Active", gncEmployeeSetActive, gncEmployeeGetActive);
-
- do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
-
- guid_new (&guid);
- employee = gncEmployeeCreate (book);
- count++;
- gncEmployeeSetGUID (employee, &guid);
- do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(employee))), "guid compare");
- }
- {
- GList *list;
-
- list = gncBusinessGetList (book, GNC_EMPLOYEE_MODULE_NAME, TRUE);
- do_test (list != NULL, "getList all");
- do_test (g_list_length (list) == count, "correct length: all");
- g_list_free (list);
-
- list = gncBusinessGetList (book, GNC_EMPLOYEE_MODULE_NAME, FALSE);
- do_test (list != NULL, "getList active");
- do_test (g_list_length (list) == 1, "correct length: active");
- g_list_free (list);
- }
- {
- const char *str = get_random_string();
- const char *res;
- GncAddress *addr;
-
- addr = gncEmployeeGetAddr (employee);
- gncAddressSetName (addr, str);
- res = qof_object_printable (GNC_ID_EMPLOYEE, employee);
- do_test (res != NULL, "Printable NULL?");
- do_test (safe_strcmp (str, res) == 0, "Printable equals");
- }
-}
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, const char *str),
- const char * (*get)(const GncEmployee *))
-{
- GncEmployee *employee = gncEmployeeCreate (book);
- char const *str = get_random_string ();
-
- 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);
- /* 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++;
-}
-
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, gnc_numeric),
- gnc_numeric (*get)(const GncEmployee *))
-{
- GncEmployee *employee = gncEmployeeCreate (book);
- gnc_numeric num = gnc_numeric_create (17, 1);
-
- 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 (gnc_numeric_equal (get (employee), num), message);
- gncEmployeeSetActive (employee, FALSE);
- count++;
-}
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, gboolean),
- gboolean (*get) (const GncEmployee *))
-{
- GncEmployee *employee = gncEmployeeCreate (book);
- gboolean num = get_random_boolean ();
-
- do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
- gncEmployeeBeginEdit (employee);
- set (employee, FALSE);
- set (employee, TRUE);
- 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);
- count++;
-}
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
- void (*set) (GncEmployee *, gint),
- gint (*get) (GncEmployee *))
-{
- GncEmployee *employee = gncEmployeeCreate (book);
- gint num = 17;
-
- 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);
- count++;
-}
-#endif
-
-int
-main (int argc, char **argv)
-{
- qof_init();
- qof_load_backend_library ("../../../backend/xml/.libs/", GNC_LIB_NAME);
- do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
- do_test (gncJobRegister (), "Cannot register GncJob");
- do_test (gncCustomerRegister(), "Cannot register GncCustomer");
- do_test (gncEmployeeRegister(), "Cannot register GncEmployee");
- test_employee();
- print_test_results();
- qof_close();
- return 0;
-}
Deleted: gnucash/trunk/src/business/business-core/test/test-job.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-job.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-job.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,266 +0,0 @@
-/*********************************************************************
- * test-job.c
- * Test the job object.
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
- *
- * 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 <glib.h>
-#include "qof.h"
-#include "gncJobP.h"
-#include "gncInvoiceP.h"
-#include "gncCustomerP.h"
-#include "gncOwner.h"
-#include "test-stuff.h"
-
-#include "gnc-backend-xml.h"
-
-#define FILE_NAME "xml:///tmp/testbook.gnucash"
-#define GNC_LIB_NAME "gncmod-backend-xml"
-
-static int count = 0;
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, const char *str),
- const char * (*get)(const GncJob *));
-
-#if 0
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, gnc_numeric),
- gnc_numeric (*get)(const GncJob *));
-#endif
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, gboolean),
- gboolean (*get) (const GncJob *));
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, gint),
- gint (*get) (const GncJob *));
-#endif
-
-static void
-test_job (void)
-{
- QofBackend *be;
- QofSession *session;
- QofBook *book;
- GncJob *job;
-
- session = qof_session_new();
- be = NULL;
- qof_session_begin(session, FILE_NAME, FALSE, FALSE, FALSE);
- book = qof_session_get_book (session);
- be = qof_book_get_backend(book);
-
- /* The book *must* have a backend to pass the test of the 'dirty' flag */
- /* See the README file for details */
- do_test (be != NULL, "xml backend could not be set");
-
- /* Test creation/destruction */
- {
- do_test (gncJobCreate (NULL) == NULL, "job create NULL");
- job = gncJobCreate (book);
- do_test (job != NULL, "job create");
- do_test (qof_instance_get_book(QOF_INSTANCE(job)) == book,
- "getbook");
-
- gncJobBeginEdit (job);
- gncJobDestroy (job);
- success ("create/destroy");
- }
-
- /* Test setting/getting routines; does the active flag get set right? */
- {
- GncGUID guid;
-
- test_string_fcn (book, "Id", gncJobSetID, gncJobGetID);
- test_string_fcn (book, "Name", gncJobSetName, gncJobGetName);
- test_string_fcn (book, "Reference", gncJobSetReference, gncJobGetReference);
-
- test_bool_fcn (book, "Active", gncJobSetActive, gncJobGetActive);
-
- guid_new (&guid);
- job = gncJobCreate (book);
- count++;
- gncJobSetGUID (job, &guid);
- do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(job))), "guid compare");
- }
-#if 0
- {
- GList *list;
-
- list = gncBusinessGetList (book, GNC_ID_JOB, TRUE);
- do_test (list != NULL, "getList all");
- do_test (g_list_length (list) == count, "correct length: all");
- g_list_free (list);
-
- list = gncBusinessGetList (book, GNC_ID_JOB, FALSE);
- do_test (list != NULL, "getList active");
- do_test (g_list_length (list) == 1, "correct length: active");
- g_list_free (list);
- }
-#endif
- {
- const char *str = get_random_string();
- const char *res;
-
- gncJobSetName (job, str);
- res = qof_object_printable (GNC_ID_JOB, job);
- do_test (res != NULL, "Printable NULL?");
- do_test (safe_strcmp (str, res) == 0, "Printable equals");
- }
- {
- GList *list;
- GncOwner owner;
- GncCustomer *cust = gncCustomerCreate (book);
-
- gncOwnerInitCustomer (&owner, cust);
-
- do_test (gncCustomerGetJoblist (cust, TRUE) == NULL, "empty list at start");
- gncJobSetOwner (job, &owner);
- list = gncCustomerGetJoblist (cust, FALSE);
- do_test (list != NULL, "added to cust");
- do_test (g_list_length (list) == 1, "correct joblist length");
- do_test (list->data == job, "verify job in list");
- gncJobSetActive (job, FALSE);
- 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);
- list = gncCustomerGetJoblist (cust, TRUE);
- do_test (list == NULL, "no more jobs");
- }
-}
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, const char *str),
- const char * (*get)(const GncJob *))
-{
- GncJob *job = gncJobCreate (book);
- char const *str = get_random_string ();
-
- 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);
- /* 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++;
-}
-
-#if 0
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, gnc_numeric),
- gnc_numeric (*get)(const GncJob *))
-{
- GncJob *job = gncJobCreate (book);
- gnc_numeric num = gnc_numeric_create (17, 1);
-
- 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);
- count++;
-}
-#endif
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, gboolean),
- gboolean (*get) (const GncJob *))
-{
- GncJob *job = gncJobCreate (book);
- gboolean num = get_random_boolean ();
-
- do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test if start dirty");
- gncJobBeginEdit (job);
- 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);
- /* 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++;
-}
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
- void (*set) (GncJob *, gint),
- gint (*get) (const GncJob *))
-{
- GncJob *job = gncJobCreate (book);
- gint num = 17;
-
- 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);
- count++;
-}
-#endif
-
-int
-main (int argc, char **argv)
-{
- qof_init();
- qof_load_backend_library ("../../../backend/xml/.libs/", GNC_LIB_NAME);
- do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
- do_test (gncJobRegister (), "Cannot register GncJob");
- do_test (gncCustomerRegister(), "Cannot register GncCustomer");
- test_job();
- print_test_results();
- qof_close();
- return 0;
-}
-
Deleted: gnucash/trunk/src/business/business-core/test/test-load-module.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-load-module.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-load-module.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,62 +0,0 @@
-/*********************************************************************
- * test-load-module.c
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <libguile.h>
-
-#include "gnc-module.h"
-
-static void
-guile_main (void *closure, int argc, char ** argv)
-{
- GNCModule module;
-
- printf(" test-load-module.c: loading/unloading business-core module ... ");
-
- gnc_module_system_init();
- module = gnc_module_load("gnucash/business-core", 0);
-
- if (!module)
- {
- printf(" Failed to load engine\n");
- exit(-1);
- }
-
- if (!gnc_module_unload(module))
- {
- printf(" Failed to unload engine\n");
- exit(-1);
- }
- printf(" successful.\n");
-
- exit(0);
-}
-
-int
-main (int argc, char ** argv)
-{
- scm_boot_guile(argc, argv, guile_main, NULL);
- return 0;
-}
Deleted: gnucash/trunk/src/business/business-core/test/test-vendor.c
===================================================================
--- gnucash/trunk/src/business/business-core/test/test-vendor.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-core/test/test-vendor.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,245 +0,0 @@
-/*********************************************************************
- * test-vendor.c
- * Test the vendor object.
- *
- * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
- * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
- *
- * 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 <glib.h>
-#include "gncInvoiceP.h"
-#include "gncCustomerP.h"
-#include "gncJobP.h"
-#include "gncVendorP.h"
-#include "test-stuff.h"
-
-#include "gnc-backend-xml.h"
-
-#define FILE_NAME "xml:///tmp/testbook.gnucash"
-#define GNC_LIB_NAME "gncmod-backend-xml"
-
-static int count = 0;
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, const char *str),
- const char * (*get)(const GncVendor *));
-
-#if 0
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, gnc_numeric),
- gnc_numeric (*get)(const GncVendor *));
-#endif
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, gboolean),
- gboolean (*get) (const GncVendor *));
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, gint),
- gint (*get) (const GncVendor *));
-#endif
-
-static void
-test_vendor (void)
-{
- QofBackend *be;
- QofSession *session;
- QofBook *book;
- GncVendor *vendor;
-
- session = qof_session_new();
- be = NULL;
- qof_session_begin(session, FILE_NAME, FALSE, FALSE, FALSE);
- book = qof_session_get_book (session);
- be = qof_book_get_backend(book);
-
- /* The book *must* have a backend to pass the test of the 'dirty' flag */
- /* See the README file for details */
- do_test (be != NULL, "xml backend could not be set");
-
- /* Test creation/destruction */
- {
- do_test (gncVendorCreate (NULL) == NULL, "vendor create NULL");
- vendor = gncVendorCreate (book);
- do_test (vendor != NULL, "vendor create");
- do_test (qof_instance_get_book (QOF_INSTANCE(vendor)) == book,
- "getbook");
-
- gncVendorBeginEdit (vendor);
- gncVendorDestroy (vendor);
- success ("create/destroy");
- }
-
- /* Test setting/getting routines; does the active flag get set right? */
- {
- GncGUID guid;
-
- test_string_fcn (book, "Id", gncVendorSetID, gncVendorGetID);
- test_string_fcn (book, "Name", gncVendorSetName, gncVendorGetName);
- test_string_fcn (book, "Notes", gncVendorSetNotes, gncVendorGetNotes);
-
- //test_string_fcn (book, "Terms", gncVendorSetTerms, gncVendorGetTerms);
-
- //test_bool_fcn (book, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded);
- test_bool_fcn (book, "Active", gncVendorSetActive, gncVendorGetActive);
-
- do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
-
- guid_new (&guid);
- vendor = gncVendorCreate (book);
- count++;
- gncVendorSetGUID (vendor, &guid);
- do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(vendor))), "guid compare");
- }
- {
- GList *list;
-
- list = gncBusinessGetList (book, GNC_ID_VENDOR, TRUE);
- do_test (list != NULL, "getList all");
- do_test (g_list_length (list) == count, "correct length: all");
- g_list_free (list);
-
- list = gncBusinessGetList (book, GNC_ID_VENDOR, FALSE);
- do_test (list != NULL, "getList active");
- do_test (g_list_length (list) == 1, "correct length: active");
- g_list_free (list);
- }
- {
- const char *str = get_random_string();
- const char *res;
-
- gncVendorSetName (vendor, str);
- res = qof_object_printable (GNC_ID_VENDOR, vendor);
- do_test (res != NULL, "Printable NULL?");
- do_test (safe_strcmp (str, res) == 0, "Printable equals");
- }
-}
-
-static void
-test_string_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, const char *str),
- const char * (*get)(const GncVendor *))
-{
- GncVendor *vendor = gncVendorCreate (book);
- char const *str = get_random_string ();
-
- 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);
- /* 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++;
-}
-
-#if 0
-static void
-test_numeric_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, gnc_numeric),
- gnc_numeric (*get)(const GncVendor *))
-{
- GncVendor *vendor = gncVendorCreate (book);
- gnc_numeric num = gnc_numeric_create (17, 1);
-
- 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);
- count++;
-}
-#endif
-
-static void
-test_bool_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, gboolean),
- gboolean (*get) (const GncVendor *))
-{
- GncVendor *vendor = gncVendorCreate (book);
- gboolean num = get_random_boolean ();
-
- do_test (!gncVendorIsDirty (vendor), "test if start dirty");
- gncVendorBeginEdit (vendor);
- set (vendor, FALSE);
- set (vendor, TRUE);
- 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);
- count++;
-}
-
-#if 0
-static void
-test_gint_fcn (QofBook *book, const char *message,
- void (*set) (GncVendor *, gint),
- gint (*get) (const GncVendor *))
-{
- GncVendor *vendor = gncVendorCreate (book);
- gint num = 17;
-
- 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);
- count++;
-}
-#endif
-
-int
-main (int argc, char **argv)
-{
- qof_init();
- qof_load_backend_library ("../../../backend/xml/.libs/", GNC_LIB_NAME);
- do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
- do_test (gncJobRegister (), "Cannot register GncJob");
- do_test (gncCustomerRegister(), "Cannot register GncCustomer");
- do_test (gncVendorRegister(), "Cannot register GncVendor");
- test_vendor();
- print_test_results();
- qof_close();
- return 0;
-}
Modified: gnucash/trunk/src/business/business-gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-gnome/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-gnome/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -14,7 +14,6 @@
-I${top_srcdir}/src/gnome-search \
-I${top_srcdir}/src/html \
-I${top_srcdir}/src/report/report-gnome \
- -I${top_srcdir}/src/business/business-core \
-I${top_srcdir}/src/business/business-ledger \
-I${top_srcdir}/src/business/dialog-tax-table \
-I${top_srcdir}/src/register/register-core \
@@ -69,7 +68,6 @@
libgncmod_business_gnome_la_LIBADD = \
${top_builddir}/src/gnome/libgnc-gnome.la \
- ${top_builddir}/src/business/business-core/libgncmod-business-core.la \
${top_builddir}/src/business/business-ledger/libgnc-business-ledger.la \
${top_builddir}/src/business/dialog-tax-table/libgncmod-dialog-tax-table.la \
${top_builddir}/src/register/register-core/libgncmod-register-core.la \
Modified: gnucash/trunk/src/business/business-gnome/business-gnome.scm
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome.scm 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-gnome/business-gnome.scm 2011-11-21 10:40:17 UTC (rev 21605)
@@ -2,7 +2,6 @@
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/gnome-utils" 0)
-(gnc:module-load "gnucash/business-core" 0)
(gnc:module-load "gnucash/business-utils" 0)
(gnc:module-load "gnucash/gnome-search" 0)
(gnc:module-load "gnucash/dialog-tax-table" 0)
Modified: gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -75,16 +75,12 @@
int
libgncmod_business_gnome_gnc_module_init(int refcount)
{
- /* load business-core: we depend on it -- and it depends on the engine */
- if (!gnc_module_load ("gnucash/business-core", 0))
- {
- return FALSE;
- }
- /* We also depend on app-utils, gnome-utils, and gnome-search modules */
+ /* load app-utils: we depend on it -- and it depends on the engine */
if (!gnc_module_load ("gnucash/app-utils", 0))
{
return FALSE;
}
+ /* We also depend on gnome-utils and gnome-search modules */
if (!gnc_module_load ("gnucash/gnome-utils", 0))
{
return FALSE;
@@ -97,32 +93,10 @@
{
return FALSE;
}
- // if (!libgncmod_business_gnome_gnc_module_load ("gnucash/report/standard-reports", 0)) {
- // return FALSE;
- // }
scm_c_eval_string("(use-modules (gnucash business-gnome))");
scm_c_eval_string("(use-modules (gnucash report business-reports))");
- // temp code until gnc:url-type is wrapped
- /*
- {
- SCM wct_gnc_url_type = scm_c_eval_string("<gnc:url-type>");
- SCM tmp;
-
- tmp = gw_wcp_assimilate_ptr(GNC_CUSTOMER_MODULE_NAME, wct_gnc_url_type);
- scm_c_define("gnc:url-type-customer", tmp);
- tmp = gw_wcp_assimilate_ptr(GNC_VENDOR_MODULE_NAME, wct_gnc_url_type);
- scm_c_define("gnc:url-type-vendor", tmp);
- tmp = gw_wcp_assimilate_ptr(GNC_EMPLOYEE_MODULE_NAME, wct_gnc_url_type);
- scm_c_define("gnc:url-type-employee", tmp);
- tmp = gw_wcp_assimilate_ptr(GNC_INVOICE_MODULE_NAME, wct_gnc_url_type);
- scm_c_define("gnc:url-type-invoice", tmp);
- tmp = gw_wcp_assimilate_ptr(URL_TYPE_OWNERREPORT, wct_gnc_url_type);
- scm_c_define("gnc:url-type-ownerreport", tmp);
- }
- */
-
if (refcount == 0)
{
/* Register the Owner search type */
Modified: gnucash/trunk/src/business/business-ledger/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-ledger/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-ledger/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -18,7 +18,6 @@
gncEntryLedgerModel.h
libgnc_business_ledger_la_LIBADD = \
- ${top_builddir}/src/business/business-core/libgncmod-business-core.la \
${top_builddir}/src/business/business-utils/libgncmod-business-utils.la \
${top_builddir}/src/business/dialog-tax-table/libgncmod-dialog-tax-table.la \
${top_builddir}/src/register/register-core/libgncmod-register-core.la \
@@ -33,7 +32,6 @@
${GLIB_LIBS}
AM_CPPFLAGS = \
- -I${top_srcdir}/src/business/business-core \
-I${top_srcdir}/src/business/business-utils \
-I${top_srcdir}/src/business/dialog-tax-table \
-I${top_srcdir}/src \
Modified: gnucash/trunk/src/business/business-utils/business-utils.scm
===================================================================
--- gnucash/trunk/src/business/business-utils/business-utils.scm 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-utils/business-utils.scm 2011-11-21 10:40:17 UTC (rev 21605)
@@ -2,7 +2,6 @@
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/app-utils" 0)
-(gnc:module-load "gnucash/business-core" 0)
(define gnc:*business-label* (N_ "Business"))
(define gnc:*company-name* (N_ "Company Name"))
Modified: gnucash/trunk/src/business/business-utils/gncmod-business-utils.c
===================================================================
--- gnucash/trunk/src/business/business-utils/gncmod-business-utils.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/business-utils/gncmod-business-utils.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -55,12 +55,6 @@
int
libgncmod_business_utils_gnc_module_init(int refcount)
{
- /* load the business-core (we depend on it) */
- if (!gnc_module_load("gnucash/business-core", 0))
- {
- return FALSE;
- }
-
/* Load the application utils.. */
if (!gnc_module_load("gnucash/app-utils", 0))
{
Modified: gnucash/trunk/src/business/dialog-tax-table/Makefile.am
===================================================================
--- gnucash/trunk/src/business/dialog-tax-table/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/dialog-tax-table/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -7,7 +7,6 @@
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/app-utils \
- -I${top_srcdir}/src/business/business-core \
-I${top_srcdir}/src/libqof/qof \
${GNOME_CFLAGS} \
${GLADE_CFLAGS} \
@@ -25,7 +24,6 @@
libgncmod_dialog_tax_table_la_LDFLAGS = -avoid-version
libgncmod_dialog_tax_table_la_LIBADD = \
- ${top_builddir}/src/business/business-core/libgncmod-business-core.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
${top_builddir}/src/engine/libgncmod-engine.la \
Modified: gnucash/trunk/src/business/dialog-tax-table/gncmod-dialog-tax-table.c
===================================================================
--- gnucash/trunk/src/business/dialog-tax-table/gncmod-dialog-tax-table.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/business/dialog-tax-table/gncmod-dialog-tax-table.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -56,16 +56,12 @@
int
libgncmod_dialog_tax_table_gnc_module_init(int refcount)
{
- /* load business-core: we depend on it -- and it depends on the engine */
- if (!gnc_module_load ("gnucash/business-core", 0))
- {
- return FALSE;
- }
- /* We also depend on app-utils and gnome-utils modules */
+ /* load app-utils: we depend on it -- and it depends on the engine */
if (!gnc_module_load ("gnucash/app-utils", 0))
{
return FALSE;
}
+ /* We also depend on the gnome-utils module */
if (!gnc_module_load ("gnucash/gnome-utils", 0))
{
return FALSE;
Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/engine/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -42,7 +42,6 @@
engine-helpers.c \
glib-helpers.c \
policy.c \
- swig-business-core.c \
gncBusGuile.c \
gncBusiness.c \
gncAddress.c \
@@ -143,7 +142,8 @@
${top_builddir}/lib/libc/libc-missing.la
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
-gncmod_DATA = engine.scm
+gncmod_DATA = engine.scm \
+ business-core.scm
gncscmdir = ${GNC_SHAREDIR}/scm
gncscm_DATA = \
@@ -195,10 +195,6 @@
$(gncinclude_HEADERS) $(noinst_HEADERS)
$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-I${top_srcdir}/src/libqof/qof -I${top_srcdir}/src -o $@ $<
-swig-business-core.c: business-core.i $(top_srcdir)/src/base-typemaps.i \
- $(gncinclude_HEADERS) $(noinst_HEADERS)
- $(SWIG) -guile $(SWIG_ARGS) -Linkage module \
- -I${top_srcdir}/src -o $@ $<
endif
iso-4217-currencies.c: iso-4217-currencies.scm iso-currencies-to-c
@@ -209,7 +205,7 @@
CLEANFILES = $(BUILT_SOURCES) .scm-links \
${SCM_FILE_LINKS}
-MAINTAINERCLEANFILES = swig-engine.c swig-business-core.c
+MAINTAINERCLEANFILES = swig-engine.c
clean-local:
rm -rf gnucash
Modified: gnucash/trunk/src/engine/business-core.i
===================================================================
--- gnucash/trunk/src/engine/business-core.i 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/engine/business-core.i 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,30 +1,5 @@
-%module sw_business_core
-%{
-/* Includes the header in the wrapper code */
-#include <config.h>
-#include <gncAddress.h>
-#include <gncBillTerm.h>
-#include <gncCustomer.h>
-#include <gncEmployee.h>
-#include <gncEntry.h>
-#include <gncInvoice.h>
-#include <gncJob.h>
-#include <gncOrder.h>
-#include <gncOwner.h>
-#include <gncTaxTable.h>
-#include <gncVendor.h>
-%}
-
#if defined(SWIGGUILE)
%{
-#include <guile-mappings.h>
-#include <gncBusGuile.h>
-#ifdef _MSC_VER
-# define snprintf _snprintf
-#endif
-#include "engine-helpers.h"
-#include "gncBusGuile.h"
-
/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when
* passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via
* gncInvoiceLookup and friends. When the macro gets inlined, the compiler
@@ -33,13 +8,9 @@
#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
# pragma GCC diagnostic warning "-Waddress"
#endif
-
-SCM scm_init_sw_business_core_module (void);
%}
#endif
-%import "base-typemaps.i"
-
%rename(gncOwnerReturnGUID) gncOwnerRetGUID;
%inline %{
Copied: gnucash/trunk/src/engine/business-core.scm (from rev 21604, gnucash/trunk/src/business/business-core/business-core.scm)
===================================================================
--- gnucash/trunk/src/engine/business-core.scm (rev 0)
+++ gnucash/trunk/src/engine/business-core.scm 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,132 @@
+(define-module (gnucash business-core))
+(use-modules (gnucash gnc-module))
+(gnc:module-load "gnucash/engine" 0)
+
+(define (gnc:owner-get-address owner)
+ (let ((type (gncOwnerGetType owner)))
+ (cond
+ ((eqv? type GNC-OWNER-CUSTOMER)
+ (let ((c (gncOwnerGetCustomer owner)))
+ (gncCustomerGetAddr c)))
+ ((eqv? type GNC-OWNER-VENDOR)
+ (let ((v (gncOwnerGetVendor owner)))
+ (gncVendorGetAddr v)))
+ ((eqv? type GNC-OWNER-EMPLOYEE)
+ (let ((e (gncOwnerGetEmployee owner)))
+ (gncEmployeeGetAddr e)))
+ ((eqv? type GNC-OWNER-JOB)
+ (gnc:owner-get-address (gncJobGetOwner
+ (gncOwnerGetJob owner))))
+ (else '()))))
+
+;
+; The -dep functions return combined strings of the appropriate
+; content. When multiple "lines" are included, separate them
+; by newlines.
+;
+; e.g.: return a string which is basically:
+; name \n Attn: contact \n addr1 \n addr2 \n addr3 \n addr4
+;
+; But only include the strings that really exist.
+;
+
+(define (gnc:owner-get-name-dep owner)
+ (define (just-name name)
+ (if name name ""))
+
+ (let ((type (gncOwnerGetType owner)))
+ (cond
+ ((eqv? type GNC-OWNER-JOB)
+ (gnc:owner-get-name-dep (gncJobGetOwner
+ (gncOwnerGetJob owner))))
+ (else (just-name (gncOwnerGetName owner))))))
+
+(define (gnc:owner-get-address-dep owner)
+ (define (add-if-exists lst new)
+ (if (and new (> (string-length new) 0))
+ (cons new lst)
+ lst))
+ (define (build-string lst)
+ (cond
+ ((null? lst) "")
+ ((null? (cdr lst)) (car lst))
+ (else (string-append (build-string (cdr lst)) "\n" (car lst)))))
+ (let ((lst '())
+ (addr (gnc:owner-get-address owner)))
+; Added gncAddressGetName <mikee at saxicola.co.uk>
+ (set! lst (add-if-exists lst (gncAddressGetName addr)))
+ (set! lst (add-if-exists lst (gncAddressGetAddr1 addr)))
+ (set! lst (add-if-exists lst (gncAddressGetAddr2 addr)))
+ (set! lst (add-if-exists lst (gncAddressGetAddr3 addr)))
+ (set! lst (add-if-exists lst (gncAddressGetAddr4 addr)))
+ (build-string lst)))
+
+(define (gnc:owner-get-name-and-address-dep owner)
+ (let ((name (gnc:owner-get-name-dep owner))
+ (addr (gnc:owner-get-address-dep owner)))
+ (if (> (string-length name) 0)
+ (string-append name "\n" addr)
+ addr)))
+
+(define (gnc:owner-get-owner-id owner)
+ (let ((type (gncOwnerGetType owner)))
+ (cond
+ ((eqv? type GNC-OWNER-CUSTOMER)
+ (let ((c (gncOwnerGetCustomer owner)))
+ (gncCustomerGetID c)))
+ ((eqv? type GNC-OWNER-VENDOR)
+ (let ((v (gncOwnerGetVendor owner)))
+ (gncVendorGetID v)))
+ ((eqv? type GNC-OWNER-EMPLOYEE)
+ (let ((e (gncOwnerGetEmployee owner)))
+ (gncEmployeeGetID e)))
+ ((eqv? type GNC-OWNER-JOB)
+ (gnc:owner-get-owner-id (gncJobGetOwner (gncOwnerGetJob owner))))
+ (else ""))))
+
+(define (gnc:entry-type-percent-p type-val)
+ (let ((type type-val))
+ (equal? type GNC-AMT-TYPE-PERCENT)))
+
+(define (gnc:owner-from-split split result-owner)
+ (let* ((trans (xaccSplitGetParent split))
+ (invoice (gncInvoiceGetInvoiceFromTxn trans))
+ (temp-owner (gncOwnerNew))
+ (owner '()))
+
+ (if (not (null? invoice))
+ (set! owner (gncInvoiceGetOwner invoice))
+ (let ((split-list (xaccTransGetSplitList trans)))
+ (define (check-splits splits)
+ (if (and splits (not (null? splits)))
+ (let* ((split (car splits))
+ (lot (xaccSplitGetLot split)))
+ (if (not (null? lot))
+ (let* ((invoice (gncInvoiceGetInvoiceFromLot lot))
+ (owner? (gncOwnerGetOwnerFromLot
+ lot temp-owner)))
+ (if (not (null? invoice))
+ (set! owner (gncInvoiceGetOwner invoice))
+ (if owner?
+ (set! owner temp-owner)
+ (check-splits (cdr splits)))))
+ (check-splits (cdr splits))))))
+ (check-splits split-list)))
+
+ (if (not (null? owner))
+ (begin
+ (gncOwnerCopy (gncOwnerGetEndOwner owner) result-owner)
+ (gncOwnerFree temp-owner)
+ result-owner)
+ (begin
+ (gncOwnerFree temp-owner)
+ '()))))
+
+
+(export gnc:owner-get-address)
+(export gnc:owner-get-name-dep)
+(export gnc:owner-get-address-dep)
+(export gnc:owner-get-name-and-address-dep)
+(export gnc:owner-get-owner-id)
+(export gnc:entry-type-percent-p)
+(export gnc:owner-from-split)
Modified: gnucash/trunk/src/engine/engine.i
===================================================================
--- gnucash/trunk/src/engine/engine.i 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/engine/engine.i 2011-11-21 10:40:17 UTC (rev 21605)
@@ -18,6 +18,19 @@
#include "kvp-scm.h"
#include "glib-helpers.h"
+#include "gncAddress.h"
+#include "gncBillTerm.h"
+#include "gncCustomer.h"
+#include "gncEmployee.h"
+#include "gncEntry.h"
+#include "gncInvoice.h"
+#include "gncJob.h"
+#include "gncOrder.h"
+#include "gncOwner.h"
+#include "gncTaxTable.h"
+#include "gncVendor.h"
+#include "gncBusGuile.h"
+
SCM scm_init_sw_engine_module (void);
%}
@@ -294,3 +307,5 @@
}
#endif
+
+%include business-core.i
Modified: gnucash/trunk/src/engine/gncmod-engine.c
===================================================================
--- gnucash/trunk/src/engine/gncmod-engine.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/engine/gncmod-engine.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -49,6 +49,7 @@
scm_init_sw_engine_module();
scm_c_eval_string("(use-modules (sw_engine))");
scm_c_eval_string("(use-modules (gnucash engine))");
+ scm_c_eval_string("(use-modules (gnucash business-core))");
return TRUE;
}
Modified: gnucash/trunk/src/engine/test/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/test/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/engine/test/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -44,7 +44,13 @@
test-transaction-reversal \
test-transaction-voiding \
test-recurrence \
- test-scm-query
+ test-scm-query \
+ test-business \
+ test-address \
+ test-customer \
+ test-employee \
+ test-job \
+ test-vendor
GNC_TEST_DEPS = \
--gnc-module-dir ${top_builddir}/src/engine \
@@ -76,7 +82,13 @@
test-scm-query \
test-split-vs-account \
test-transaction-reversal \
- test-transaction-voiding
+ test-transaction-voiding \
+ test-business \
+ test-address \
+ test-customer \
+ test-employee \
+ test-job \
+ test-vendor
test_link_SOURCES = test-link.c
Modified: gnucash/trunk/src/engine/test/README
===================================================================
--- gnucash/trunk/src/engine/test/README 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/engine/test/README 2011-11-21 10:40:17 UTC (rev 21605)
@@ -1,7 +1,41 @@
-This directory contains unit test cases to excercise basic
+This directory contains unit test cases to exercise basic
GnuCash engine functions.
To run the tests, just do 'make check'
+Notes on test of dirty/clean flag:
+---------------------------------
+This test is currently performed in part in
+test-customer
+test-employee
+test-job
+test-vendor
+
+The test cases will check if the dirty flag is unset on creation
+of an object and if the dirty flag is set when the object
+is modified.
+
+There used to be a test also to check if the dirty flag is
+cleared again upon committing the change.
+This test has been removed, because it can only be successful
+if a backend is set up. That's because the 'dirty' flag is
+supposed to be cleared by the backend only.
+
+We are in the engine test code however. In here it's not possible
+to load a backend without creating some circular dependencies
+between gnucash modules.
+
+Just for completeness, this was said on the dirty flag tests before
+these test cases got moved to the engine:
+"An object cannot be marked 'clean' unless it has actually
+been saved to a file or sql db. (Or, in the case of the file
+backend, the 'dirtiness' of the data has been duly noted, and
+will be taken care of for the next file save.
+Until its saved, it lives in perpetual dirtiness. Thus, the
+test cases need to specify a backend, then do the commit,
+then test the dirty flag.
+
+Actually, the use of the dirty flag in gnucash is, at this time,
+mildly ambiguous, and its semantics are not clearly defined."
\ No newline at end of file
Copied: gnucash/trunk/src/engine/test/test-address.c (from rev 21604, gnucash/trunk/src/business/business-core/test/test-address.c)
===================================================================
--- gnucash/trunk/src/engine/test/test-address.c (rev 0)
+++ gnucash/trunk/src/engine/test/test-address.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,99 @@
+/*********************************************************************
+ * test-address.c
+ * object definition/initialization for Address
+ *
+ * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
+ *
+ * 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 <glib.h>
+#include "cashobjects.h"
+#include "gncAddressP.h"
+#include "test-stuff.h"
+
+static void
+test_string_fcn (GncAddress *address, const char *message,
+ void (*set) (GncAddress *, const char *str),
+ const char * (*get)(const GncAddress *));
+
+static void
+test_address (void)
+{
+ QofInstance *ent;
+ GncAddress *address;
+ QofBook *book = qof_book_new ();
+
+ ent = g_object_new(QOF_TYPE_INSTANCE, "guid", guid_null(), NULL);
+ ent->e_type = "asdf";
+
+ /* Test creation/destruction */
+ {
+ do_test (gncAddressCreate (NULL, NULL) == NULL, "address create NULL");
+
+ address = gncAddressCreate (book, ent);
+ do_test (address != NULL, "address create");
+
+ gncAddressBeginEdit (address);
+ gncAddressDestroy (address);
+ success ("create/destroy");
+ }
+
+ /* Test setting routines */
+ {
+ address = gncAddressCreate (book, ent);
+ test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName);
+ test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1);
+ test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2);
+ test_string_fcn (address, "Addr3", gncAddressSetAddr3, gncAddressGetAddr3);
+ test_string_fcn (address, "Addr4", gncAddressSetAddr4, gncAddressGetAddr4);
+ test_string_fcn (address, "Phone", gncAddressSetPhone, gncAddressGetPhone);
+ test_string_fcn (address, "Fax", gncAddressSetFax, gncAddressGetFax);
+ test_string_fcn (address, "Email", gncAddressSetEmail, gncAddressGetEmail);
+ }
+}
+
+static void
+test_string_fcn (GncAddress *address, const char *message,
+ void (*set) (GncAddress *, const char *str),
+ const char * (*get)(const GncAddress *))
+{
+ char const *str = get_random_string ();
+
+ do_test (!gncAddressIsDirty (address), "test if start dirty");
+ set (address, str);
+ do_test (gncAddressIsDirty (address), "test dirty later");
+ do_test (safe_strcmp (get (address), str) == 0, message);
+ gncAddressClearDirty (address);
+}
+
+int
+main (int argc, char **argv)
+{
+ qof_init();
+ if (cashobjects_register())
+ {
+ test_address();
+ print_test_results();
+ }
+ qof_close();
+ return 0;
+}
Copied: gnucash/trunk/src/engine/test/test-business.c (from rev 21604, gnucash/trunk/src/business/business-core/test/test-business.c)
===================================================================
--- gnucash/trunk/src/engine/test/test-business.c (rev 0)
+++ gnucash/trunk/src/engine/test/test-business.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,138 @@
+/*********************************************************************
+ * test-business.c
+ * Test the business code.
+ *
+ * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ *
+ * 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 <glib.h>
+#include <libguile.h>
+
+#include "qof.h"
+#include "gnc-module.h"
+
+#include "gncBusiness.h"
+#include "test-stuff.h"
+
+#define TEST_MODULE_NAME "business-test"
+#define TEST_MODULE_DESC "Test Business"
+
+#if 0
+static GList * get_list (QofBook *, gboolean show_all);
+static const char * printable (gpointer obj);
+static void test_printable (const char *name, gpointer obj);
+static void test_get_list (QofBook *, const char *);
+
+static GncBusinessObject bus_obj =
+{
+ GNC_BUSINESS_VERSION,
+ TEST_MODULE_NAME,
+ TEST_MODULE_DESC,
+ NULL, /* create */
+ NULL, /* destroy */
+ get_list,
+ printable,
+};
+
+static void test_business (void)
+{
+ /* Test the global registration and lookup functions */
+ {
+ do_test (!gncBusinessRegister (NULL), "register NULL");
+ do_test (gncBusinessRegister (&bus_obj), "register test object");
+ do_test (!gncBusinessRegister (&bus_obj), "register test object again");
+ do_test (gncBusinessLookup (TEST_MODULE_NAME) == &bus_obj,
+ "lookup our installed object");
+ do_test (gncBusinessLookup ("snm98sn snml say dyikh9y9ha") == NULL,
+ "lookup non-existant business object");
+
+ do_test (!safe_strcmp (gncBusinessGetTypeLabel (TEST_MODULE_NAME),
+ _(TEST_MODULE_DESC)),
+ "test description return");
+ }
+
+ test_get_list ((QofBook*)1, TEST_MODULE_NAME);
+ test_printable (TEST_MODULE_NAME, (gpointer)1);
+}
+
+static GList *
+get_list (QofBook *book, gboolean show_all)
+{
+ do_test (book != NULL, "get_list: NULL business");
+ success ("called get_list callback");
+ return ((GList *)1);
+}
+
+static const char *
+printable (gpointer obj)
+{
+ do_test (obj != NULL, "printable: object is NULL");
+ success ("called printable callback");
+ return ((const char *)obj);
+}
+
+static void
+test_get_list (QofBook *book, const char *name)
+{
+ GList *res;
+
+ do_test (gncBusinessGetList (NULL, NULL, FALSE) == NULL,
+ "business: GetList: NULL, NULL, FALSE");
+ do_test (gncBusinessGetList (NULL, name, FALSE) == NULL,
+ "business: GetList: NULL, mod_name, FALSE");
+ do_test (gncBusinessGetList (book, NULL, FALSE) == NULL,
+ "business: GetList: book, NULL, FALSE");
+ res = gncBusinessGetList (book, name, FALSE);
+ do_test (res != NULL, "business: GetList: book, mod_name, FALSE");
+}
+
+static void
+test_printable (const char *name, gpointer obj)
+{
+ const char *res;
+
+ do_test (gncBusinessPrintable (NULL, NULL) == NULL,
+ "business: Printable: NULL, NULL");
+ do_test (gncBusinessPrintable (NULL, obj) == NULL,
+ "business: Printable: NULL, object");
+ do_test (gncBusinessPrintable (name, NULL) == NULL,
+ "business: Printable: mod_name, NULL");
+ res = gncBusinessPrintable (name, obj);
+ do_test (res != NULL, "business: Printable: mod_name, object");
+}
+
+static void
+main_helper (void *closure, int argc, char **argv)
+{
+ gnc_module_load("gnucash/engine", 0);
+ test_business();
+ print_test_results();
+ exit(get_rv());
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+ // scm_boot_guile (argc, argv, main_helper, NULL);
+ return 0;
+}
Copied: gnucash/trunk/src/engine/test/test-customer.c (from rev 21604, gnucash/trunk/src/business/business-core/test/test-customer.c)
===================================================================
--- gnucash/trunk/src/engine/test/test-customer.c (rev 0)
+++ gnucash/trunk/src/engine/test/test-customer.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,230 @@
+/*********************************************************************
+ * test-customer.c
+ * Test the customer object (without Guile/Scheme)
+ *
+ * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
+ *
+ * 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 <glib.h>
+#include "qof.h"
+#include "cashobjects.h"
+#include "gncCustomerP.h"
+#include "gncInvoiceP.h"
+#include "gncJobP.h"
+#include "test-stuff.h"
+
+static int count = 0;
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncCustomer *, const char *str),
+ const char * (*get)(const GncCustomer *));
+
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncCustomer *, gnc_numeric),
+ gnc_numeric (*get)(const GncCustomer *));
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncCustomer *, gboolean),
+ gboolean (*get) (const GncCustomer *));
+
+static void
+test_customer (void)
+{
+ QofBook *book;
+ GncCustomer *customer;
+
+ book = qof_book_new ();
+
+ /* Test creation/destruction */
+ {
+ do_test (gncCustomerCreate (NULL) == NULL, "customer create NULL");
+ customer = gncCustomerCreate (book);
+ do_test (customer != NULL, "customer create");
+ do_test (gncCustomerGetBook (customer) == book, "getbook");
+
+ gncCustomerBeginEdit (customer);
+ gncCustomerDestroy (customer);
+ success ("create/destroy");
+ }
+
+ /* Test setting/getting routines; does the active flag get set right? */
+ {
+ GncGUID guid;
+
+ test_string_fcn (book, "Id", gncCustomerSetID, gncCustomerGetID);
+ test_string_fcn (book, "Name", gncCustomerSetName, gncCustomerGetName);
+ test_string_fcn (book, "Notes", gncCustomerSetNotes, gncCustomerGetNotes);
+
+ //test_string_fcn (book, "Terms", gncCustomerSetTerms, gncCustomerGetTerms);
+
+ test_numeric_fcn (book, "Discount", gncCustomerSetDiscount, gncCustomerGetDiscount);
+ test_numeric_fcn (book, "Credit", gncCustomerSetCredit, gncCustomerGetCredit);
+
+ test_bool_fcn (book, "Active", gncCustomerSetActive, gncCustomerGetActive);
+
+ do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
+ do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
+
+ guid_new (&guid);
+ customer = gncCustomerCreate (book);
+ count++;
+ gncCustomerSetGUID (customer, &guid);
+ do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare");
+ }
+ {
+ GList *list;
+
+ list = gncBusinessGetList (book, GNC_ID_CUSTOMER, TRUE);
+ do_test (list != NULL, "getList all");
+ do_test (g_list_length (list) == count, "correct length: all");
+ g_list_free (list);
+
+ list = gncBusinessGetList (book, GNC_ID_CUSTOMER, FALSE);
+ do_test (list != NULL, "getList active");
+ do_test (g_list_length (list) == 1, "correct length: active");
+ g_list_free (list);
+ }
+ {
+ const char *str = get_random_string();
+ const char *res;
+
+ res = NULL;
+ gncCustomerBeginEdit(customer);
+ gncCustomerSetName (customer, str);
+ gncCustomerCommitEdit(customer);
+ res = qof_object_printable (GNC_ID_CUSTOMER, customer);
+ do_test (res != NULL, "Printable NULL?");
+ do_test (safe_strcmp (str, res) == 0, "Printable equals");
+ }
+
+ do_test (gncCustomerGetJoblist (customer, TRUE) == NULL, "joblist empty");
+
+ /* Test the Entity Table */
+ {
+ const GncGUID *guid;
+
+ guid = gncCustomerGetGUID (customer);
+ do_test (gncCustomerLookup (book, guid) == customer, "Entity Table");
+ }
+
+ /* Note: JobList is tested from the Job tests */
+ qof_book_destroy (book);
+}
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncCustomer *, const char *str),
+ const char * (*get)(const GncCustomer *))
+{
+ GncCustomer *customer = gncCustomerCreate (book);
+ char const *str = get_random_string ();
+
+ 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);
+ /* Customer record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
+ do_test (safe_strcmp (get (customer), str) == 0, message);
+ gncCustomerSetActive (customer, FALSE);
+ count++;
+}
+
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncCustomer *, gnc_numeric),
+ gnc_numeric (*get)(const GncCustomer *))
+{
+ GncCustomer *customer = gncCustomerCreate (book);
+ gnc_numeric num = gnc_numeric_create (17, 1);
+
+ 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);
+ /* Customer record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
+ do_test (gnc_numeric_equal (get (customer), num), message);
+ gncCustomerSetActive (customer, FALSE);
+ count++;
+}
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncCustomer *, gboolean),
+ gboolean (*get) (const GncCustomer *))
+{
+ GncCustomer *customer = gncCustomerCreate (book);
+ gboolean num = get_random_boolean ();
+
+ do_test (!gncCustomerIsDirty (customer), "test if start dirty");
+ gncCustomerBeginEdit (customer);
+ set (customer, FALSE);
+ set (customer, TRUE);
+ set (customer, num);
+ /* Customer record should be dirty */
+ do_test (gncCustomerIsDirty (customer), "test dirty later");
+ gncCustomerCommitEdit (customer);
+ /* Customer record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
+ do_test (get (customer) == num, message);
+ gncCustomerSetActive (customer, FALSE);
+ count++;
+}
+
+int
+main (int argc, char **argv)
+{
+ qof_init();
+ 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 ();
+ return 0;
+}
Copied: gnucash/trunk/src/engine/test/test-employee.c (from rev 21604, gnucash/trunk/src/business/business-core/test/test-employee.c)
===================================================================
--- gnucash/trunk/src/engine/test/test-employee.c (rev 0)
+++ gnucash/trunk/src/engine/test/test-employee.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,247 @@
+/*********************************************************************
+ * test-employee.c
+ * Test the employee object (without Guile).
+ *
+ * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
+ *
+ * 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 <glib.h>
+#include "qof.h"
+#include "gncEmployeeP.h"
+#include "gncCustomerP.h"
+#include "gncJobP.h"
+#include "gncInvoiceP.h"
+#include "test-stuff.h"
+
+static int count = 0;
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, const char *str),
+ const char * (*get)(const GncEmployee *));
+
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, gnc_numeric),
+ gnc_numeric (*get)(const GncEmployee *));
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, gboolean),
+ gboolean (*get) (const GncEmployee *));
+
+#if 0
+static void
+test_gint_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, gint),
+ gint (*get) (GncEmployee *));
+#endif
+
+static void
+test_employee (void)
+{
+ QofBook *book;
+ GncEmployee *employee;
+
+ book = qof_book_new();
+
+ /* Test creation/destruction */
+ {
+ do_test (gncEmployeeCreate (NULL) == NULL, "employee create NULL");
+ employee = gncEmployeeCreate (book);
+ do_test (employee != NULL, "employee create");
+ do_test (qof_instance_get_book(QOF_INSTANCE(employee)) == book,
+ "getbook");
+
+ gncEmployeeBeginEdit (employee);
+ gncEmployeeDestroy (employee);
+ success ("create/destroy");
+ }
+
+ /* Test setting/getting routines; does the active flag get set right? */
+ {
+ GncGUID guid;
+
+ test_string_fcn (book, "Id", gncEmployeeSetID, gncEmployeeGetID);
+ test_string_fcn (book, "Username", gncEmployeeSetUsername, gncEmployeeGetUsername);
+ test_string_fcn (book, "Language", gncEmployeeSetLanguage, gncEmployeeGetLanguage);
+ test_string_fcn (book, "Acl", gncEmployeeSetAcl, gncEmployeeGetAcl);
+
+ test_numeric_fcn (book, "Workday", gncEmployeeSetWorkday, gncEmployeeGetWorkday);
+ test_numeric_fcn (book, "Rate", gncEmployeeSetRate, gncEmployeeGetRate);
+
+ test_bool_fcn (book, "Active", gncEmployeeSetActive, gncEmployeeGetActive);
+
+ do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
+
+ guid_new (&guid);
+ employee = gncEmployeeCreate (book);
+ count++;
+ gncEmployeeSetGUID (employee, &guid);
+ do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(employee))), "guid compare");
+ }
+ {
+ GList *list;
+
+ list = gncBusinessGetList (book, GNC_EMPLOYEE_MODULE_NAME, TRUE);
+ do_test (list != NULL, "getList all");
+ do_test (g_list_length (list) == count, "correct length: all");
+ g_list_free (list);
+
+ list = gncBusinessGetList (book, GNC_EMPLOYEE_MODULE_NAME, FALSE);
+ do_test (list != NULL, "getList active");
+ do_test (g_list_length (list) == 1, "correct length: active");
+ g_list_free (list);
+ }
+ {
+ const char *str = get_random_string();
+ const char *res;
+ GncAddress *addr;
+
+ addr = gncEmployeeGetAddr (employee);
+ gncAddressSetName (addr, str);
+ res = qof_object_printable (GNC_ID_EMPLOYEE, employee);
+ do_test (res != NULL, "Printable NULL?");
+ do_test (safe_strcmp (str, res) == 0, "Printable equals");
+ }
+
+ qof_book_destroy (book);
+}
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, const char *str),
+ const char * (*get)(const GncEmployee *))
+{
+ GncEmployee *employee = gncEmployeeCreate (book);
+ char const *str = get_random_string ();
+
+ 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);
+ /* Employee record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+ do_test (safe_strcmp (get (employee), str) == 0, message);
+ gncEmployeeSetActive (employee, FALSE);
+ count++;
+}
+
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, gnc_numeric),
+ gnc_numeric (*get)(const GncEmployee *))
+{
+ GncEmployee *employee = gncEmployeeCreate (book);
+ gnc_numeric num = gnc_numeric_create (17, 1);
+
+ 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 */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+ do_test (gnc_numeric_equal (get (employee), num), message);
+ gncEmployeeSetActive (employee, FALSE);
+ count++;
+}
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, gboolean),
+ gboolean (*get) (const GncEmployee *))
+{
+ GncEmployee *employee = gncEmployeeCreate (book);
+ gboolean num = get_random_boolean ();
+
+ do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
+ gncEmployeeBeginEdit (employee);
+ set (employee, FALSE);
+ set (employee, TRUE);
+ set (employee, num);
+ /* Employee record should be dirty */
+ do_test (gncEmployeeIsDirty (employee), "test dirty later");
+ gncEmployeeCommitEdit (employee);
+ /* Employee record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+ do_test (get (employee) == num, message);
+ gncEmployeeSetActive (employee, FALSE);
+ count++;
+}
+
+#if 0
+static void
+test_gint_fcn (QofBook *book, const char *message,
+ void (*set) (GncEmployee *, gint),
+ gint (*get) (GncEmployee *))
+{
+ GncEmployee *employee = gncEmployeeCreate (book);
+ gint num = 17;
+
+ 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 */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
+ do_test (get (employee) == num, message);
+ gncEmployeeSetActive (employee, FALSE);
+ count++;
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+ qof_init();
+ do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
+ do_test (gncJobRegister (), "Cannot register GncJob");
+ do_test (gncCustomerRegister(), "Cannot register GncCustomer");
+ do_test (gncEmployeeRegister(), "Cannot register GncEmployee");
+ test_employee();
+ print_test_results();
+ qof_close();
+ return 0;
+}
Copied: gnucash/trunk/src/engine/test/test-job.c (from rev 21604, gnucash/trunk/src/business/business-core/test/test-job.c)
===================================================================
--- gnucash/trunk/src/engine/test/test-job.c (rev 0)
+++ gnucash/trunk/src/engine/test/test-job.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,268 @@
+/*********************************************************************
+ * test-job.c
+ * Test the job object.
+ *
+ * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
+ *
+ * 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 <glib.h>
+#include "qof.h"
+#include "gncJobP.h"
+#include "gncInvoiceP.h"
+#include "gncCustomerP.h"
+#include "gncOwner.h"
+#include "test-stuff.h"
+
+static int count = 0;
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, const char *str),
+ const char * (*get)(const GncJob *));
+
+#if 0
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, gnc_numeric),
+ gnc_numeric (*get)(const GncJob *));
+#endif
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, gboolean),
+ gboolean (*get) (const GncJob *));
+
+#if 0
+static void
+test_gint_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, gint),
+ gint (*get) (const GncJob *));
+#endif
+
+static void
+test_job (void)
+{
+ QofBook *book;
+ GncJob *job;
+
+ book = qof_book_new();
+
+ /* Test creation/destruction */
+ {
+ do_test (gncJobCreate (NULL) == NULL, "job create NULL");
+ job = gncJobCreate (book);
+ do_test (job != NULL, "job create");
+ do_test (qof_instance_get_book(QOF_INSTANCE(job)) == book,
+ "getbook");
+
+ gncJobBeginEdit (job);
+ gncJobDestroy (job);
+ success ("create/destroy");
+ }
+
+ /* Test setting/getting routines; does the active flag get set right? */
+ {
+ GncGUID guid;
+
+ test_string_fcn (book, "Id", gncJobSetID, gncJobGetID);
+ test_string_fcn (book, "Name", gncJobSetName, gncJobGetName);
+ test_string_fcn (book, "Reference", gncJobSetReference, gncJobGetReference);
+
+ test_bool_fcn (book, "Active", gncJobSetActive, gncJobGetActive);
+
+ guid_new (&guid);
+ job = gncJobCreate (book);
+ count++;
+ gncJobSetGUID (job, &guid);
+ do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(job))), "guid compare");
+ }
+#if 0
+ {
+ GList *list;
+
+ list = gncBusinessGetList (book, GNC_ID_JOB, TRUE);
+ do_test (list != NULL, "getList all");
+ do_test (g_list_length (list) == count, "correct length: all");
+ g_list_free (list);
+
+ list = gncBusinessGetList (book, GNC_ID_JOB, FALSE);
+ do_test (list != NULL, "getList active");
+ do_test (g_list_length (list) == 1, "correct length: active");
+ g_list_free (list);
+ }
+#endif
+ {
+ const char *str = get_random_string();
+ const char *res;
+
+ gncJobSetName (job, str);
+ res = qof_object_printable (GNC_ID_JOB, job);
+ do_test (res != NULL, "Printable NULL?");
+ do_test (safe_strcmp (str, res) == 0, "Printable equals");
+ }
+ {
+ GList *list;
+ GncOwner owner;
+ GncCustomer *cust = gncCustomerCreate (book);
+
+ gncOwnerInitCustomer (&owner, cust);
+
+ do_test (gncCustomerGetJoblist (cust, TRUE) == NULL, "empty list at start");
+ gncJobSetOwner (job, &owner);
+ list = gncCustomerGetJoblist (cust, FALSE);
+ do_test (list != NULL, "added to cust");
+ do_test (g_list_length (list) == 1, "correct joblist length");
+ do_test (list->data == job, "verify job in list");
+ gncJobSetActive (job, FALSE);
+ 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);
+ list = gncCustomerGetJoblist (cust, TRUE);
+ do_test (list == NULL, "no more jobs");
+ }
+
+ qof_book_destroy (book);
+}
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, const char *str),
+ const char * (*get)(const GncJob *))
+{
+ GncJob *job = gncJobCreate (book);
+ char const *str = get_random_string ();
+
+ 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);
+ /* Job record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // 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++;
+}
+
+#if 0
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, gnc_numeric),
+ gnc_numeric (*get)(const GncJob *))
+{
+ GncJob *job = gncJobCreate (book);
+ gnc_numeric num = gnc_numeric_create (17, 1);
+
+ 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 */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // 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);
+ count++;
+}
+#endif
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, gboolean),
+ gboolean (*get) (const GncJob *))
+{
+ GncJob *job = gncJobCreate (book);
+ gboolean num = get_random_boolean ();
+
+ do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test if start dirty");
+ gncJobBeginEdit (job);
+ 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);
+ /* Job record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
+ do_test (get (job) == num, message);
+ gncJobSetActive (job, FALSE);
+ count++;
+}
+
+#if 0
+static void
+test_gint_fcn (QofBook *book, const char *message,
+ void (*set) (GncJob *, gint),
+ gint (*get) (const GncJob *))
+{
+ GncJob *job = gncJobCreate (book);
+ gint num = 17;
+
+ 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 */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!qof_instance_is_dirty (QOF_INSTANCE(job)), "test dirty after commit");
+ do_test (get (job) == num, message);
+ gncJobSetActive (job, FALSE);
+ count++;
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+ qof_init();
+ do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
+ do_test (gncJobRegister (), "Cannot register GncJob");
+ do_test (gncCustomerRegister(), "Cannot register GncCustomer");
+ test_job();
+ print_test_results();
+ qof_close();
+ return 0;
+}
+
Copied: gnucash/trunk/src/engine/test/test-vendor.c (from rev 21604, gnucash/trunk/src/business/business-core/test/test-vendor.c)
===================================================================
--- gnucash/trunk/src/engine/test/test-vendor.c (rev 0)
+++ gnucash/trunk/src/engine/test/test-vendor.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -0,0 +1,249 @@
+/*********************************************************************
+ * test-vendor.c
+ * Test the vendor object.
+ *
+ * Copyright (c) 2001 Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
+ *
+ * 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 <glib.h>
+#include "gncInvoiceP.h"
+#include "gncCustomerP.h"
+#include "gncJobP.h"
+#include "gncVendorP.h"
+#include "test-stuff.h"
+
+static int count = 0;
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, const char *str),
+ const char * (*get)(const GncVendor *));
+
+#if 0
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, gnc_numeric),
+ gnc_numeric (*get)(const GncVendor *));
+#endif
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, gboolean),
+ gboolean (*get) (const GncVendor *));
+
+#if 0
+static void
+test_gint_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, gint),
+ gint (*get) (const GncVendor *));
+#endif
+
+static void
+test_vendor (void)
+{
+ QofBackend *be;
+ QofSession *session;
+ QofBook *book;
+ GncVendor *vendor;
+
+ book = qof_book_new();
+
+ /* Test creation/destruction */
+ {
+ do_test (gncVendorCreate (NULL) == NULL, "vendor create NULL");
+ vendor = gncVendorCreate (book);
+ do_test (vendor != NULL, "vendor create");
+ do_test (qof_instance_get_book (QOF_INSTANCE(vendor)) == book,
+ "getbook");
+
+ gncVendorBeginEdit (vendor);
+ gncVendorDestroy (vendor);
+ success ("create/destroy");
+ }
+
+ /* Test setting/getting routines; does the active flag get set right? */
+ {
+ GncGUID guid;
+
+ test_string_fcn (book, "Id", gncVendorSetID, gncVendorGetID);
+ test_string_fcn (book, "Name", gncVendorSetName, gncVendorGetName);
+ test_string_fcn (book, "Notes", gncVendorSetNotes, gncVendorGetNotes);
+
+ //test_string_fcn (book, "Terms", gncVendorSetTerms, gncVendorGetTerms);
+
+ //test_bool_fcn (book, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded);
+ test_bool_fcn (book, "Active", gncVendorSetActive, gncVendorGetActive);
+
+ do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
+
+ guid_new (&guid);
+ vendor = gncVendorCreate (book);
+ count++;
+ gncVendorSetGUID (vendor, &guid);
+ do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(vendor))), "guid compare");
+ }
+ {
+ GList *list;
+
+ list = gncBusinessGetList (book, GNC_ID_VENDOR, TRUE);
+ do_test (list != NULL, "getList all");
+ do_test (g_list_length (list) == count, "correct length: all");
+ g_list_free (list);
+
+ list = gncBusinessGetList (book, GNC_ID_VENDOR, FALSE);
+ do_test (list != NULL, "getList active");
+ do_test (g_list_length (list) == 1, "correct length: active");
+ g_list_free (list);
+ }
+ {
+ const char *str = get_random_string();
+ const char *res;
+
+ gncVendorSetName (vendor, str);
+ res = qof_object_printable (GNC_ID_VENDOR, vendor);
+ do_test (res != NULL, "Printable NULL?");
+ do_test (safe_strcmp (str, res) == 0, "Printable equals");
+ }
+
+ qof_book_destroy (book);
+}
+
+static void
+test_string_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, const char *str),
+ const char * (*get)(const GncVendor *))
+{
+ GncVendor *vendor = gncVendorCreate (book);
+ char const *str = get_random_string ();
+
+ 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);
+ /* Vendor record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
+ do_test (safe_strcmp (get (vendor), str) == 0, message);
+ gncVendorSetActive (vendor, FALSE);
+ count++;
+}
+
+#if 0
+static void
+test_numeric_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, gnc_numeric),
+ gnc_numeric (*get)(const GncVendor *))
+{
+ GncVendor *vendor = gncVendorCreate (book);
+ gnc_numeric num = gnc_numeric_create (17, 1);
+
+ 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 */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
+ do_test (gnc_numeric_equal (get (vendor), num), message);
+ gncVendorSetActive (vendor, FALSE);
+ count++;
+}
+#endif
+
+static void
+test_bool_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, gboolean),
+ gboolean (*get) (const GncVendor *))
+{
+ GncVendor *vendor = gncVendorCreate (book);
+ gboolean num = get_random_boolean ();
+
+ do_test (!gncVendorIsDirty (vendor), "test if start dirty");
+ gncVendorBeginEdit (vendor);
+ set (vendor, FALSE);
+ set (vendor, TRUE);
+ set (vendor, num);
+ /* Vendor record should be dirty */
+ do_test (gncVendorIsDirty (vendor), "test dirty later");
+ gncVendorCommitEdit (vendor);
+ /* Vendor record should be not dirty */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
+ do_test (get (vendor) == num, message);
+ gncVendorSetActive (vendor, FALSE);
+ count++;
+}
+
+#if 0
+static void
+test_gint_fcn (QofBook *book, const char *message,
+ void (*set) (GncVendor *, gint),
+ gint (*get) (const GncVendor *))
+{
+ GncVendor *vendor = gncVendorCreate (book);
+ gint num = 17;
+
+ 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 */
+ /* Skip, because will always fail without a backend.
+ * It's not possible to load a backend in the engine code
+ * without having circular dependencies.
+ */
+ // do_test (!gncVendorIsDirty (vendor), "test dirty after commit");
+ do_test (get (vendor) == num, message);
+ gncVendorSetActive (vendor, FALSE);
+ count++;
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+ qof_init();
+ do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
+ do_test (gncJobRegister (), "Cannot register GncJob");
+ do_test (gncCustomerRegister(), "Cannot register GncCustomer");
+ do_test (gncVendorRegister(), "Cannot register GncVendor");
+ test_vendor();
+ print_test_results();
+ qof_close();
+ return 0;
+}
Modified: gnucash/trunk/src/optional/python-bindings/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/python-bindings/Makefile.am 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/optional/python-bindings/Makefile.am 2011-11-21 10:40:17 UTC (rev 21605)
@@ -21,7 +21,6 @@
-I${top_srcdir}/src/libqof/qof \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/engine \
- -I$(top_srcdir)/src/business/business-core \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/gnc-module \
@@ -76,7 +75,6 @@
gnucash_core.c: $(SWIG_FILES) ${top_srcdir}/src/base-typemaps.i ${top_srcdir}/src/engine/engine-common.i $(_gnucash_core_c_includes)
swig -python -Wall -Werror \
-I$(top_srcdir)/src -I$(top_srcdir)/src/engine \
- -I$(top_srcdir)/src/business/business-core \
-I${top_srcdir}/src/libqof/qof \
-o $@ $<
Modified: gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c 2011-11-21 10:40:17 UTC (rev 21605)
@@ -73,10 +73,6 @@
{
return FALSE;
}
- if (!gnc_module_load ("gnucash/business-core", 0))
- {
- return FALSE;
- }
if (!gnc_module_load ("gnucash/engine", 0))
{
return FALSE;
Modified: gnucash/trunk/src/report/business-reports/aging.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/aging.scm 2011-11-21 05:43:38 UTC (rev 21604)
+++ gnucash/trunk/src/report/business-reports/aging.scm 2011-11-21 10:40:17 UTC (rev 21605)
@@ -31,7 +31,6 @@
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/report/report-system" 0)
-(gnc:module-load "gnucash/business-core" 0)
(use-modules (gnucash report standard-reports))
(use-modules (gnucash report business-reports))
More information about the gnucash-changes
mailing list